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 <ardb@kernel.org>
This commit is contained in:
Ard Biesheuvel 2025-01-16 16:48:31 +01:00 committed by mergify[bot]
parent 298d8c436a
commit 337a99af10
5 changed files with 61 additions and 77 deletions

View File

@ -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);
}

View File

@ -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_

View File

@ -1,57 +0,0 @@
/** @file
*
* Copyright (c) 2011-2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/
#include <Base.h>
#include <Library/ArmGicLib.h>
#include <Library/ArmLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
/**
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);
}

View File

@ -14,8 +14,6 @@
LIBRARY_CLASS = ArmGicLib
[Sources]
ArmGicLib.c
GicV2/ArmGicV2Lib.c
GicV2/ArmGicV2NonSecLib.c

View File

@ -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