The data type used by variables representing the
GicInterruptInterfaceBase has been inconsistently
used in the ArmGic driver and the library.
The PCD defined for the GIC Interrupt interface
base address is UINT64. However, the data types
for the variables used is UINTN, INTN, and at
some places UINT32.
Therefore, update the data types to use UINTN and
add necessary typecasts when reading values from
the PCD. This should then be consistent across
AArch32 and AArch64 builds.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
ArmPkg/Drivers/ArmGic/ArmGicLib.c | 13 ++++++++++---
ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c | 2 +-
ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c | 6 +++---
ArmPkg/Include/Library/ArmGicLib.h | 18 +++++++++---------
4 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
index 6e44e89390fcdaa89302d6505f75c43c84ce3535..78edc7e76a087caa5b91d896f9bd316d6530a668 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
@@ -104,10 +104,17 @@ GicGetCpuRedistributorBase (
return 0;
}
+/**
+ Return the GIC CPU Interrupt Interface ID.
+
+ @param GicInterruptInterfaceBase Base address of the GIC Interrupt Interface.
+
+ @retval CPU Interface Identification information.
+**/
UINTN
EFIAPI
ArmGicGetInterfaceIdentification (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
)
{
// Read the GIC Identification Register
@@ -400,7 +407,7 @@ ArmGicDisableDistributor (
VOID
EFIAPI
ArmGicEnableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
)
{
ARM_GIC_ARCH_REVISION Revision;
@@ -418,7 +425,7 @@ ArmGicEnableInterruptInterface (
VOID
EFIAPI
ArmGicDisableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
)
{
ARM_GIC_ARCH_REVISION Revision;
diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
index b7d67d830e46b663e4054990e7456660fb22cda9..b952c3ae31c060ecbb43c0800d34e57664a8262a 100644
--- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
+++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
@@ -400,7 +400,7 @@ GicV2DxeInitialize (
// the system.
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
- mGicInterruptInterfaceBase = PcdGet64 (PcdGicInterruptInterfaceBase);
+ mGicInterruptInterfaceBase = (UINTN)PcdGet64 (PcdGicInterruptInterfaceBase);
mGicDistributorBase = (UINTN)PcdGet64 (PcdGicDistributorBase);
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase);
diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c
index 85c2a920a54a1acaccb98a94b5591ce36d20697c..832f21644233655ef2f359f1e175071d2a493b7c 100644
--- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c
+++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
@@ -13,7 +13,7 @@
VOID
EFIAPI
ArmGicV2EnableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
)
{
/*
@@ -26,7 +26,7 @@ ArmGicV2EnableInterruptInterface (
VOID
EFIAPI
ArmGicV2DisableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
)
{
// Disable Gic Interface
diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h
index 72dbd1ca8d626c69d9bb8727d77fd34b4ab3af28..41bbf1da6a6cbb683df4bb30c4b1a1762dc7814f 100644
--- a/ArmPkg/Include/Library/ArmGicLib.h
+++ b/ArmPkg/Include/Library/ArmGicLib.h
@@ -113,7 +113,7 @@
UINTN
EFIAPI
ArmGicGetInterfaceIdentification (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
);
// GIC Secure interfaces
@@ -122,7 +122,7 @@ EFIAPI
ArmGicSetupNonSecure (
IN UINTN MpId,
IN UINTN GicDistributorBase,
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
);
VOID
@@ -136,13 +136,13 @@ ArmGicSetSecureInterrupts (
VOID
EFIAPI
ArmGicEnableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
);
VOID
EFIAPI
ArmGicDisableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
);
VOID
@@ -203,8 +203,8 @@ ArmGicEndOfInterrupt (
UINTN
EFIAPI
ArmGicSetPriorityMask (
- IN INTN GicInterruptInterfaceBase,
- IN INTN PriorityMask
+ IN UINTN GicInterruptInterfaceBase,
+ IN INTN PriorityMask
);
VOID
@@ -252,19 +252,19 @@ EFIAPI
ArmGicV2SetupNonSecure (
IN UINTN MpId,
IN UINTN GicDistributorBase,
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
);
VOID
EFIAPI
ArmGicV2EnableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
);
VOID
EFIAPI
ArmGicV2DisableInterruptInterface (
- IN INTN GicInterruptInterfaceBase
+ IN UINTN GicInterruptInterfaceBase
);
UINTN
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105179): https://edk2.groups.io/g/devel/message/105179
Mute This Topic: https://groups.io/mt/99086460/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
On Tue, 23 May 2023 at 15:04, Sami Mujawar <sami.mujawar@arm.com> wrote: > > The data type used by variables representing the > GicInterruptInterfaceBase has been inconsistently > used in the ArmGic driver and the library. > The PCD defined for the GIC Interrupt interface > base address is UINT64. However, the data types > for the variables used is UINTN, INTN, and at > some places UINT32. > > Therefore, update the data types to use UINTN and > add necessary typecasts when reading values from > the PCD. This should then be consistent across > AArch32 and AArch64 builds. > OK, so in general, I would prefer EFI_PHYSICAL_ADDRESS to represent MMIO register addresses, given that those are physical addresses. However, as nobody in their right mind would create a 32-bit CPU with its GIC registers located at an address that is not 32-bit addressable, using UINTN is acceptable here, as the codegen will be much nicer on 32-bit ARM. And INTN is obviously not the right type here. > Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> > --- > ArmPkg/Drivers/ArmGic/ArmGicLib.c | 13 ++++++++++--- > ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c | 2 +- > ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c | 6 +++--- > ArmPkg/Include/Library/ArmGicLib.h | 18 +++++++++--------- > 4 files changed, 23 insertions(+), 16 deletions(-) > > diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > index 6e44e89390fcdaa89302d6505f75c43c84ce3535..78edc7e76a087caa5b91d896f9bd316d6530a668 100644 > --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c > +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > @@ -104,10 +104,17 @@ GicGetCpuRedistributorBase ( > return 0; > } > > +/** > + Return the GIC CPU Interrupt Interface ID. > + > + @param GicInterruptInterfaceBase Base address of the GIC Interrupt Interface. > + > + @retval CPU Interface Identification information. > +**/ > UINTN > EFIAPI > ArmGicGetInterfaceIdentification ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > // Read the GIC Identification Register > @@ -400,7 +407,7 @@ ArmGicDisableDistributor ( > VOID > EFIAPI > ArmGicEnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > ARM_GIC_ARCH_REVISION Revision; > @@ -418,7 +425,7 @@ ArmGicEnableInterruptInterface ( > VOID > EFIAPI > ArmGicDisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > ARM_GIC_ARCH_REVISION Revision; > diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c > index b7d67d830e46b663e4054990e7456660fb22cda9..b952c3ae31c060ecbb43c0800d34e57664a8262a 100644 > --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c > +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c > @@ -400,7 +400,7 @@ GicV2DxeInitialize ( > // the system. > ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid); > > - mGicInterruptInterfaceBase = PcdGet64 (PcdGicInterruptInterfaceBase); > + mGicInterruptInterfaceBase = (UINTN)PcdGet64 (PcdGicInterruptInterfaceBase); > mGicDistributorBase = (UINTN)PcdGet64 (PcdGicDistributorBase); > mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase); > > diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c > index 85c2a920a54a1acaccb98a94b5591ce36d20697c..832f21644233655ef2f359f1e175071d2a493b7c 100644 > --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c > +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c > @@ -1,6 +1,6 @@ > /** @file > * > -* Copyright (c) 2011-2014, ARM Limited. All rights reserved. > +* Copyright (c) 2011-2021, Arm Limited. All rights reserved. > * > * SPDX-License-Identifier: BSD-2-Clause-Patent > * > @@ -13,7 +13,7 @@ > VOID > EFIAPI > ArmGicV2EnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > /* > @@ -26,7 +26,7 @@ ArmGicV2EnableInterruptInterface ( > VOID > EFIAPI > ArmGicV2DisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > // Disable Gic Interface > diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h > index 72dbd1ca8d626c69d9bb8727d77fd34b4ab3af28..41bbf1da6a6cbb683df4bb30c4b1a1762dc7814f 100644 > --- a/ArmPkg/Include/Library/ArmGicLib.h > +++ b/ArmPkg/Include/Library/ArmGicLib.h > @@ -113,7 +113,7 @@ > UINTN > EFIAPI > ArmGicGetInterfaceIdentification ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > // GIC Secure interfaces > @@ -122,7 +122,7 @@ EFIAPI > ArmGicSetupNonSecure ( > IN UINTN MpId, > IN UINTN GicDistributorBase, > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > @@ -136,13 +136,13 @@ ArmGicSetSecureInterrupts ( > VOID > EFIAPI > ArmGicEnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > EFIAPI > ArmGicDisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > @@ -203,8 +203,8 @@ ArmGicEndOfInterrupt ( > UINTN > EFIAPI > ArmGicSetPriorityMask ( > - IN INTN GicInterruptInterfaceBase, > - IN INTN PriorityMask > + IN UINTN GicInterruptInterfaceBase, > + IN INTN PriorityMask > ); > > VOID > @@ -252,19 +252,19 @@ EFIAPI > ArmGicV2SetupNonSecure ( > IN UINTN MpId, > IN UINTN GicDistributorBase, > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > EFIAPI > ArmGicV2EnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > EFIAPI > ArmGicV2DisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > UINTN > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105192): https://edk2.groups.io/g/devel/message/105192 Mute This Topic: https://groups.io/mt/99086460/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
On Tue, May 23, 2023 at 2:04 PM Sami Mujawar <sami.mujawar@arm.com> wrote: > > The data type used by variables representing the > GicInterruptInterfaceBase has been inconsistently > used in the ArmGic driver and the library. > The PCD defined for the GIC Interrupt interface > base address is UINT64. However, the data types > for the variables used is UINTN, INTN, and at > some places UINT32. > > Therefore, update the data types to use UINTN and > add necessary typecasts when reading values from > the PCD. This should then be consistent across > AArch32 and AArch64 builds. > > Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> > --- > ArmPkg/Drivers/ArmGic/ArmGicLib.c | 13 ++++++++++--- > ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c | 2 +- > ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c | 6 +++--- > ArmPkg/Include/Library/ArmGicLib.h | 18 +++++++++--------- > 4 files changed, 23 insertions(+), 16 deletions(-) > > diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > index 6e44e89390fcdaa89302d6505f75c43c84ce3535..78edc7e76a087caa5b91d896f9bd316d6530a668 100644 > --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c > +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > @@ -104,10 +104,17 @@ GicGetCpuRedistributorBase ( > return 0; > } > > +/** > + Return the GIC CPU Interrupt Interface ID. > + > + @param GicInterruptInterfaceBase Base address of the GIC Interrupt Interface. > + > + @retval CPU Interface Identification information. > +**/ > UINTN > EFIAPI > ArmGicGetInterfaceIdentification ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > // Read the GIC Identification Register > @@ -400,7 +407,7 @@ ArmGicDisableDistributor ( > VOID > EFIAPI > ArmGicEnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > ARM_GIC_ARCH_REVISION Revision; > @@ -418,7 +425,7 @@ ArmGicEnableInterruptInterface ( > VOID > EFIAPI > ArmGicDisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > ARM_GIC_ARCH_REVISION Revision; > diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c > index b7d67d830e46b663e4054990e7456660fb22cda9..b952c3ae31c060ecbb43c0800d34e57664a8262a 100644 > --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c > +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c > @@ -400,7 +400,7 @@ GicV2DxeInitialize ( > // the system. > ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid); > > - mGicInterruptInterfaceBase = PcdGet64 (PcdGicInterruptInterfaceBase); > + mGicInterruptInterfaceBase = (UINTN)PcdGet64 (PcdGicInterruptInterfaceBase); > mGicDistributorBase = (UINTN)PcdGet64 (PcdGicDistributorBase); > mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase); > ASSERT'ing for PCD <= MAX_UINTN may be desirable here, for both bases? > diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c > index 85c2a920a54a1acaccb98a94b5591ce36d20697c..832f21644233655ef2f359f1e175071d2a493b7c 100644 > --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c > +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c > @@ -1,6 +1,6 @@ > /** @file > * > -* Copyright (c) 2011-2014, ARM Limited. All rights reserved. > +* Copyright (c) 2011-2021, Arm Limited. All rights reserved. > * > * SPDX-License-Identifier: BSD-2-Clause-Patent > * > @@ -13,7 +13,7 @@ > VOID > EFIAPI > ArmGicV2EnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > /* > @@ -26,7 +26,7 @@ ArmGicV2EnableInterruptInterface ( > VOID > EFIAPI > ArmGicV2DisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ) > { > // Disable Gic Interface > diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h > index 72dbd1ca8d626c69d9bb8727d77fd34b4ab3af28..41bbf1da6a6cbb683df4bb30c4b1a1762dc7814f 100644 > --- a/ArmPkg/Include/Library/ArmGicLib.h > +++ b/ArmPkg/Include/Library/ArmGicLib.h > @@ -113,7 +113,7 @@ > UINTN > EFIAPI > ArmGicGetInterfaceIdentification ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > // GIC Secure interfaces > @@ -122,7 +122,7 @@ EFIAPI > ArmGicSetupNonSecure ( > IN UINTN MpId, > IN UINTN GicDistributorBase, > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > @@ -136,13 +136,13 @@ ArmGicSetSecureInterrupts ( > VOID > EFIAPI > ArmGicEnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > EFIAPI > ArmGicDisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > @@ -203,8 +203,8 @@ ArmGicEndOfInterrupt ( > UINTN > EFIAPI > ArmGicSetPriorityMask ( > - IN INTN GicInterruptInterfaceBase, > - IN INTN PriorityMask > + IN UINTN GicInterruptInterfaceBase, > + IN INTN PriorityMask > ); > > VOID > @@ -252,19 +252,19 @@ EFIAPI > ArmGicV2SetupNonSecure ( > IN UINTN MpId, > IN UINTN GicDistributorBase, > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > EFIAPI > ArmGicV2EnableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > VOID > EFIAPI > ArmGicV2DisableInterruptInterface ( > - IN INTN GicInterruptInterfaceBase > + IN UINTN GicInterruptInterfaceBase > ); > > UINTN > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > -- Pedro -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105191): https://edk2.groups.io/g/devel/message/105191 Mute This Topic: https://groups.io/mt/99086460/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Hi Pedro, Thank you for the feedback. Please see my response inline marked [SAMI]. Regards, Sami Mujawar On 23/05/2023 02:35 pm, Pedro Falcato wrote: > On Tue, May 23, 2023 at 2:04 PM Sami Mujawar <sami.mujawar@arm.com> wrote: >> The data type used by variables representing the >> GicInterruptInterfaceBase has been inconsistently >> used in the ArmGic driver and the library. >> The PCD defined for the GIC Interrupt interface >> base address is UINT64. However, the data types >> for the variables used is UINTN, INTN, and at >> some places UINT32. >> >> Therefore, update the data types to use UINTN and >> add necessary typecasts when reading values from >> the PCD. This should then be consistent across >> AArch32 and AArch64 builds. >> >> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> >> --- >> ArmPkg/Drivers/ArmGic/ArmGicLib.c | 13 ++++++++++--- >> ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c | 2 +- >> ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c | 6 +++--- >> ArmPkg/Include/Library/ArmGicLib.h | 18 +++++++++--------- >> 4 files changed, 23 insertions(+), 16 deletions(-) >> >> diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c >> index 6e44e89390fcdaa89302d6505f75c43c84ce3535..78edc7e76a087caa5b91d896f9bd316d6530a668 100644 >> --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c >> +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c >> @@ -104,10 +104,17 @@ GicGetCpuRedistributorBase ( >> return 0; >> } >> >> +/** >> + Return the GIC CPU Interrupt Interface ID. >> + >> + @param GicInterruptInterfaceBase Base address of the GIC Interrupt Interface. >> + >> + @retval CPU Interface Identification information. >> +**/ >> UINTN >> EFIAPI >> ArmGicGetInterfaceIdentification ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ) >> { >> // Read the GIC Identification Register >> @@ -400,7 +407,7 @@ ArmGicDisableDistributor ( >> VOID >> EFIAPI >> ArmGicEnableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ) >> { >> ARM_GIC_ARCH_REVISION Revision; >> @@ -418,7 +425,7 @@ ArmGicEnableInterruptInterface ( >> VOID >> EFIAPI >> ArmGicDisableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ) >> { >> ARM_GIC_ARCH_REVISION Revision; >> diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c >> index b7d67d830e46b663e4054990e7456660fb22cda9..b952c3ae31c060ecbb43c0800d34e57664a8262a 100644 >> --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c >> +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c >> @@ -400,7 +400,7 @@ GicV2DxeInitialize ( >> // the system. >> ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid); >> >> - mGicInterruptInterfaceBase = PcdGet64 (PcdGicInterruptInterfaceBase); >> + mGicInterruptInterfaceBase = (UINTN)PcdGet64 (PcdGicInterruptInterfaceBase); >> mGicDistributorBase = (UINTN)PcdGet64 (PcdGicDistributorBase); >> mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase); >> > ASSERT'ing for PCD <= MAX_UINTN may be desirable here, for both bases? [SAMI] I will address this in the v2 series. > >> diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c >> index 85c2a920a54a1acaccb98a94b5591ce36d20697c..832f21644233655ef2f359f1e175071d2a493b7c 100644 >> --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c >> +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c >> @@ -1,6 +1,6 @@ >> /** @file >> * >> -* Copyright (c) 2011-2014, ARM Limited. All rights reserved. >> +* Copyright (c) 2011-2021, Arm Limited. All rights reserved. >> * >> * SPDX-License-Identifier: BSD-2-Clause-Patent >> * >> @@ -13,7 +13,7 @@ >> VOID >> EFIAPI >> ArmGicV2EnableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ) >> { >> /* >> @@ -26,7 +26,7 @@ ArmGicV2EnableInterruptInterface ( >> VOID >> EFIAPI >> ArmGicV2DisableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ) >> { >> // Disable Gic Interface >> diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h >> index 72dbd1ca8d626c69d9bb8727d77fd34b4ab3af28..41bbf1da6a6cbb683df4bb30c4b1a1762dc7814f 100644 >> --- a/ArmPkg/Include/Library/ArmGicLib.h >> +++ b/ArmPkg/Include/Library/ArmGicLib.h >> @@ -113,7 +113,7 @@ >> UINTN >> EFIAPI >> ArmGicGetInterfaceIdentification ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ); >> >> // GIC Secure interfaces >> @@ -122,7 +122,7 @@ EFIAPI >> ArmGicSetupNonSecure ( >> IN UINTN MpId, >> IN UINTN GicDistributorBase, >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ); >> >> VOID >> @@ -136,13 +136,13 @@ ArmGicSetSecureInterrupts ( >> VOID >> EFIAPI >> ArmGicEnableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ); >> >> VOID >> EFIAPI >> ArmGicDisableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ); >> >> VOID >> @@ -203,8 +203,8 @@ ArmGicEndOfInterrupt ( >> UINTN >> EFIAPI >> ArmGicSetPriorityMask ( >> - IN INTN GicInterruptInterfaceBase, >> - IN INTN PriorityMask >> + IN UINTN GicInterruptInterfaceBase, >> + IN INTN PriorityMask >> ); >> >> VOID >> @@ -252,19 +252,19 @@ EFIAPI >> ArmGicV2SetupNonSecure ( >> IN UINTN MpId, >> IN UINTN GicDistributorBase, >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ); >> >> VOID >> EFIAPI >> ArmGicV2EnableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ); >> >> VOID >> EFIAPI >> ArmGicV2DisableInterruptInterface ( >> - IN INTN GicInterruptInterfaceBase >> + IN UINTN GicInterruptInterfaceBase >> ); >> >> UINTN >> -- >> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >> > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105200): https://edk2.groups.io/g/devel/message/105200 Mute This Topic: https://groups.io/mt/99086460/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.