diff options
| author | Sami Mujawar <sami.mujawar@arm.com> | 2026-05-23 14:11:38 +0100 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2026-07-21 10:25:17 +0000 |
| commit | 28526dbba322e043c8089706f8e8e4c78012ee10 (patch) | |
| tree | eb9f270de08c2d6f59daa5214ec77709c49728f1 /ArmVirtPkg | |
| parent | b2b548c05750105d51fe86770974fffc1bafd50a (diff) | |
| download | edk2-28526dbba322e043c8089706f8e8e4c78012ee10.tar.gz edk2-28526dbba322e043c8089706f8e8e4c78012ee10.zip | |
ArmVirtPkg: Map GIC MMIO ranges before configuring GIC
Discover the GIC register ranges from the device tree and map them into
the GCD memory map before ArmGicDxe configures the interrupt controller.
Map the distributor and redistributor ranges for GICv3, and the
distributor and CPU interface ranges for GICv2, using MapMmioLib.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'ArmVirtPkg')
| -rw-r--r-- | ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 62 | ||||
| -rw-r--r-- | ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf | 3 |
2 files changed, 63 insertions, 2 deletions
diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c index b41f2660ff..2db53186ec 100644 --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c @@ -2,6 +2,7 @@ NULL library class implementation to discover the GIC for DT based virt platforms
Copyright (c) 2015 - 2016, Linaro Ltd. All rights reserved.<BR>
+ Copyright (c) 2026, Arm Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -13,6 +14,7 @@ #include <Library/ArmGicLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
+#include <Library/MapMmioLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
@@ -31,6 +33,7 @@ ArmVirtGicArchLibConstructor ( UINTN GicRevision;
EFI_STATUS Status;
UINT64 DistBase, CpuBase, RedistBase;
+ UINT64 DistSize, CpuSize, RedistSize;
RETURN_STATUS PcdStatus;
Status = gBS->LocateProtocol (
@@ -84,10 +87,14 @@ ArmVirtGicArchLibConstructor ( // RegProp[0..1] == { GICD base, GICD size }
DistBase = SwapBytes64 (Reg[0]);
ASSERT (DistBase < MAX_UINTN);
+ DistSize = SwapBytes64 (Reg[1]);
+ ASSERT (DistSize < MAX_UINTN);
// RegProp[2..3] == { GICR base, GICR size }
RedistBase = SwapBytes64 (Reg[2]);
ASSERT (RedistBase < MAX_UINTN);
+ RedistSize = SwapBytes64 (Reg[3]);
+ ASSERT (RedistSize < MAX_UINTN);
PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
ASSERT_RETURN_ERROR (PcdStatus);
@@ -96,11 +103,38 @@ ArmVirtGicArchLibConstructor ( DEBUG ((
DEBUG_INFO,
- "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",
+ "Found GIC v3 Distributor @ 0x%Lx, Len 0x%Lx\n",
DistBase,
- RedistBase
+ DistSize
));
+ DEBUG ((
+ DEBUG_INFO,
+ "Found GIC v3 Redistributor @ 0x%Lx, Len 0x%Lx\n",
+ RedistBase,
+ RedistSize
+ ));
+
+ Status = MapMmioMemory (
+ DistBase,
+ DistSize,
+ (EFI_MEMORY_UC | EFI_MEMORY_XP)
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return (RETURN_STATUS)Status;
+ }
+
+ Status = MapMmioMemory (
+ RedistBase,
+ RedistSize,
+ (EFI_MEMORY_UC | EFI_MEMORY_XP)
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return (RETURN_STATUS)Status;
+ }
+
break;
case 2:
@@ -112,9 +146,13 @@ ArmVirtGicArchLibConstructor ( ASSERT ((RegSize == 32) || (RegSize == 64));
DistBase = SwapBytes64 (Reg[0]);
+ DistSize = SwapBytes64 (Reg[1]);
CpuBase = SwapBytes64 (Reg[2]);
+ CpuSize = SwapBytes64 (Reg[3]);
ASSERT (DistBase < MAX_UINTN);
ASSERT (CpuBase < MAX_UINTN);
+ ASSERT (DistSize < MAX_UINTN);
+ ASSERT (CpuSize < MAX_UINTN);
PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
ASSERT_RETURN_ERROR (PcdStatus);
@@ -123,6 +161,26 @@ ArmVirtGicArchLibConstructor ( DEBUG ((DEBUG_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));
+ Status = MapMmioMemory (
+ DistBase,
+ DistSize,
+ (EFI_MEMORY_UC | EFI_MEMORY_XP)
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return (RETURN_STATUS)Status;
+ }
+
+ Status = MapMmioMemory (
+ CpuBase,
+ CpuSize,
+ (EFI_MEMORY_UC | EFI_MEMORY_XP)
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return (RETURN_STATUS)Status;
+ }
+
break;
default:
diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf index a653ba68c9..ff65a6876d 100644 --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.inf @@ -3,6 +3,7 @@ # Component description file for ArmVirtGicArchLib module
#
# Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
+# Copyright (c) 2026, Arm Ltd. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -24,6 +25,7 @@ BaseLib
DebugLib
PcdLib
+ MapMmioLib
UefiBootServicesTableLib
[Packages]
@@ -31,6 +33,7 @@ ArmVirtPkg/ArmVirtPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
[Protocols]
gFdtClientProtocolGuid ## CONSUMES
|
