From 337a99af10693bb682e4ba79f393146f21930d4f Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 16 Jan 2025 16:48:31 +0100 Subject: [PATCH] ArmPkg/ArmGic: Move remaining shared code into ArmGicDxe Move the remaining ArmGicLib code that is shared between the v2 and v3 GIC DXE drivers into ArmGicCommonDxe.c Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c | 43 +++++++++++++++++++ ArmPkg/Drivers/ArmGic/ArmGicDxe.h | 18 ++++++++ ArmPkg/Drivers/ArmGic/ArmGicLib.c | 57 ------------------------- ArmPkg/Drivers/ArmGic/ArmGicLib.inf | 2 - ArmPkg/Include/Library/ArmGicLib.h | 18 -------- 5 files changed, 61 insertions(+), 77 deletions(-) delete mode 100644 ArmPkg/Drivers/ArmGic/ArmGicLib.c diff --git a/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c b/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c index c285c27fdd..8e845511d6 100644 --- a/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c +++ b/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c @@ -199,3 +199,46 @@ InstallAndRegisterInterruptService ( return Status; } + +/** + Return the GIC CPU Interrupt Interface ID. + + @param GicInterruptInterfaceBase Base address of the GIC Interrupt Interface. + + @retval CPU Interface Identification information. +**/ +UINT32 +EFIAPI +ArmGicGetInterfaceIdentification ( + IN UINTN GicInterruptInterfaceBase + ) +{ + // Read the GIC Identification Register + return MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIIDR); +} + +UINTN +EFIAPI +ArmGicGetMaxNumInterrupts ( + IN UINTN GicDistributorBase + ) +{ + UINTN ItLines; + + ItLines = MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F; + + // + // Interrupt ID 1020-1023 are reserved. + // + return (ItLines == 0x1f) ? 1020 : 32 * (ItLines + 1); +} + +VOID +EFIAPI +ArmGicDisableDistributor ( + IN UINTN GicDistributorBase + ) +{ + // Disable Gic Distributor + MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x0); +} diff --git a/ArmPkg/Drivers/ArmGic/ArmGicDxe.h b/ArmPkg/Drivers/ArmGic/ArmGicDxe.h index 0f621682a1..4e09989843 100644 --- a/ArmPkg/Drivers/ArmGic/ArmGicDxe.h +++ b/ArmPkg/Drivers/ArmGic/ArmGicDxe.h @@ -75,4 +75,22 @@ GicGetDistributorIcfgBaseAndBit ( OUT UINTN *Config1Bit ); +UINT32 +EFIAPI +ArmGicGetInterfaceIdentification ( + IN UINTN GicInterruptInterfaceBase + ); + +VOID +EFIAPI +ArmGicDisableDistributor ( + IN UINTN GicDistributorBase + ); + +UINTN +EFIAPI +ArmGicGetMaxNumInterrupts ( + IN UINTN GicDistributorBase + ); + #endif // ARM_GIC_DXE_H_ diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c deleted file mode 100644 index 61d5dacba2..0000000000 --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c +++ /dev/null @@ -1,57 +0,0 @@ -/** @file -* -* Copyright (c) 2011-2023, Arm Limited. All rights reserved. -* -* SPDX-License-Identifier: BSD-2-Clause-Patent -* -**/ - -#include -#include -#include -#include -#include -#include - -/** - Return the GIC CPU Interrupt Interface ID. - - @param GicInterruptInterfaceBase Base address of the GIC Interrupt Interface. - - @retval CPU Interface Identification information. -**/ -UINT32 -EFIAPI -ArmGicGetInterfaceIdentification ( - IN UINTN GicInterruptInterfaceBase - ) -{ - // Read the GIC Identification Register - return MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIIDR); -} - -UINTN -EFIAPI -ArmGicGetMaxNumInterrupts ( - IN UINTN GicDistributorBase - ) -{ - UINTN ItLines; - - ItLines = MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F; - - // - // Interrupt ID 1020-1023 are reserved. - // - return (ItLines == 0x1f) ? 1020 : 32 * (ItLines + 1); -} - -VOID -EFIAPI -ArmGicDisableDistributor ( - IN UINTN GicDistributorBase - ) -{ - // Disable Gic Distributor - MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x0); -} diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf index 808ed993e1..c79bcbad37 100644 --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.inf +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.inf @@ -14,8 +14,6 @@ LIBRARY_CLASS = ArmGicLib [Sources] - ArmGicLib.c - GicV2/ArmGicV2Lib.c GicV2/ArmGicV2NonSecLib.c diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h index bb2e415e69..a0781361d9 100644 --- a/ArmPkg/Include/Library/ArmGicLib.h +++ b/ArmPkg/Include/Library/ArmGicLib.h @@ -110,24 +110,6 @@ // Bit Mask for #define ARM_GIC_ICCIAR_ACKINTID 0x3FF -UINT32 -EFIAPI -ArmGicGetInterfaceIdentification ( - IN UINTN GicInterruptInterfaceBase - ); - -VOID -EFIAPI -ArmGicDisableDistributor ( - IN UINTN GicDistributorBase - ); - -UINTN -EFIAPI -ArmGicGetMaxNumInterrupts ( - IN UINTN GicDistributorBase - ); - // GIC revision 2 specific declarations // Interrupts from 1020 to 1023 are considered as special interrupts