uefi stuff
This commit is contained in:
@@ -0,0 +1,222 @@
|
||||
From 46b642a3280d98a5db55226295c4e0371dc9dd4f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Mon, 11 Dec 2023 06:39:02 +0200
|
||||
Subject: [PATCH 01/16] Platform/RaspberryPi: Use PCDs for base addresses in
|
||||
RpiFirmwareDxe
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
All peripheral offsets defined in Bcm2836.h have changed with BCM2712.
|
||||
|
||||
Therefore, start moving drivers that we plan on reusing for Pi 5 to
|
||||
plain PCDs, but keep the old definitions in place as they're still being
|
||||
used by Pi3/4 ACPI code.
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
.../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 16 +++++++------
|
||||
.../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf | 3 ++-
|
||||
.../PlatformLib/AArch64/RaspberryPiHelper.S | 1 +
|
||||
Platform/RaspberryPi/RPi3/RPi3.dsc | 5 ++++
|
||||
Platform/RaspberryPi/RPi4/RPi4.dsc | 5 ++++
|
||||
Platform/RaspberryPi/RaspberryPi.dec | 1 +
|
||||
.../Include/IndustryStandard/Bcm2836.h | 9 -------
|
||||
.../Include/IndustryStandard/Bcm2836Mbox.h | 24 +++++++++++++++++++
|
||||
8 files changed, 47 insertions(+), 17 deletions(-)
|
||||
create mode 100644 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Mbox.h
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
index 4edec0ad..6fe76e1d 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
@@ -21,11 +21,13 @@
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
-#include <IndustryStandard/Bcm2836.h>
|
||||
+#include <IndustryStandard/Bcm2836Mbox.h>
|
||||
#include <IndustryStandard/RpiMbox.h>
|
||||
|
||||
#include <Protocol/RpiFirmware.h>
|
||||
|
||||
+#define MBOX_BASE_ADDRESS PcdGet64 (PcdFwMailboxBaseAddress)
|
||||
+
|
||||
//
|
||||
// The number of statically allocated buffer pages
|
||||
//
|
||||
@@ -51,12 +53,12 @@ DrainMailbox (
|
||||
//
|
||||
Tries = 0;
|
||||
do {
|
||||
- Val = MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
|
||||
+ Val = MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
|
||||
if (Val & (1U << BCM2836_MBOX_STATUS_EMPTY)) {
|
||||
return TRUE;
|
||||
}
|
||||
ArmDataSynchronizationBarrier ();
|
||||
- MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
|
||||
+ MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
|
||||
} while (++Tries < RPI_MBOX_MAX_TRIES);
|
||||
|
||||
return FALSE;
|
||||
@@ -76,7 +78,7 @@ MailboxWaitForStatusCleared (
|
||||
//
|
||||
Tries = 0;
|
||||
do {
|
||||
- Val = MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
|
||||
+ Val = MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
|
||||
if ((Val & StatusMask) == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -121,7 +123,7 @@ MailboxTransaction (
|
||||
//
|
||||
// Start the mailbox transaction
|
||||
//
|
||||
- MmioWrite32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_WRITE_OFFSET,
|
||||
+ MmioWrite32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_WRITE_OFFSET,
|
||||
(UINT32)((UINTN)mDmaBufferBusAddress | Channel));
|
||||
|
||||
ArmDataSynchronizationBarrier ();
|
||||
@@ -139,7 +141,7 @@ MailboxTransaction (
|
||||
// Read back the result
|
||||
//
|
||||
ArmDataSynchronizationBarrier ();
|
||||
- *Result = MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
|
||||
+ *Result = MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
|
||||
ArmDataSynchronizationBarrier ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -954,7 +956,7 @@ RpiFirmwareAllocFb (
|
||||
}
|
||||
|
||||
*Pitch = Cmd->Pitch.Pitch;
|
||||
- *FbBase = Cmd->AllocFb.AlignmentBase - BCM2836_DMA_DEVICE_OFFSET;
|
||||
+ *FbBase = Cmd->AllocFb.AlignmentBase - PcdGet64 (PcdDmaDeviceOffset);
|
||||
*FbSize = Cmd->AllocFb.Size;
|
||||
ReleaseSpinLock (&mMailboxLock);
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
index a3fc0fa4..08acc4b3 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
@@ -41,7 +41,8 @@
|
||||
gRaspberryPiFirmwareProtocolGuid ## PRODUCES
|
||||
|
||||
[FixedPcd]
|
||||
- gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress
|
||||
+ gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
|
||||
index 7008aaf8..d3c77be2 100644
|
||||
--- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
|
||||
+++ b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <AsmMacroIoLibV8.h>
|
||||
#include <Library/ArmLib.h>
|
||||
#include <IndustryStandard/Bcm2836.h>
|
||||
+#include <IndustryStandard/Bcm2836Mbox.h>
|
||||
#include <IndustryStandard/RpiMbox.h>
|
||||
|
||||
.macro drain
|
||||
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
|
||||
index f5361ab9..5e90f421 100644
|
||||
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
|
||||
@@ -446,6 +446,11 @@
|
||||
gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x09
|
||||
gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x09
|
||||
|
||||
+ #
|
||||
+ # Mailbox
|
||||
+ #
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress|0x3f00b880
|
||||
+
|
||||
## Default Terminal Type
|
||||
## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
|
||||
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
index 4e91eb9a..4ab6a819 100644
|
||||
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
@@ -452,6 +452,11 @@
|
||||
gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x32
|
||||
gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x33
|
||||
|
||||
+ #
|
||||
+ # Mailbox
|
||||
+ #
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress|0xfe00b880
|
||||
+
|
||||
#
|
||||
# Fixed CPU settings.
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
|
||||
index 6bd16a5a..d0025cf6 100644
|
||||
--- a/Platform/RaspberryPi/RaspberryPi.dec
|
||||
+++ b/Platform/RaspberryPi/RaspberryPi.dec
|
||||
@@ -50,6 +50,7 @@
|
||||
gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq1|0x0|UINT32|0x00000034
|
||||
gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x0|UINT32|0x00000035
|
||||
gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x0|UINT32|0x00000036
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress|0x0|UINT64|0x00000037
|
||||
|
||||
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
|
||||
gRaspberryPiTokenSpaceGuid.PcdCpuClock|0|UINT32|0x0000000d
|
||||
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
|
||||
index a930c64a..93d5eee9 100644
|
||||
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
|
||||
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
|
||||
@@ -57,15 +57,6 @@
|
||||
#define BCM2836_MBOX_OFFSET 0x0000b880
|
||||
#define BCM2836_MBOX_BASE_ADDRESS (BCM2836_SOC_REGISTERS + BCM2836_MBOX_OFFSET)
|
||||
#define BCM2836_MBOX_LENGTH 0x00000024
|
||||
-#define BCM2836_MBOX_READ_OFFSET 0x00000000
|
||||
-#define BCM2836_MBOX_STATUS_OFFSET 0x00000018
|
||||
-#define BCM2836_MBOX_CONFIG_OFFSET 0x0000001c
|
||||
-#define BCM2836_MBOX_WRITE_OFFSET 0x00000020
|
||||
-
|
||||
-#define BCM2836_MBOX_STATUS_FULL 0x1f
|
||||
-#define BCM2836_MBOX_STATUS_EMPTY 0x1e
|
||||
-
|
||||
-#define BCM2836_MBOX_NUM_CHANNELS 16
|
||||
|
||||
/* interrupt controller constants */
|
||||
#define BCM2836_INTC_TIMER_CONTROL_OFFSET 0x00000040
|
||||
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Mbox.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Mbox.h
|
||||
new file mode 100644
|
||||
index 00000000..f9096548
|
||||
--- /dev/null
|
||||
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Mbox.h
|
||||
@@ -0,0 +1,24 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2020, Pete Batard <pete@akeo.ie>
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#ifndef __BCM2836_MBOX_H__
|
||||
+#define __BCM2836_MBOX_H__
|
||||
+
|
||||
+/* Mailbox registers */
|
||||
+#define BCM2836_MBOX_READ_OFFSET 0x00000000
|
||||
+#define BCM2836_MBOX_STATUS_OFFSET 0x00000018
|
||||
+#define BCM2836_MBOX_CONFIG_OFFSET 0x0000001c
|
||||
+#define BCM2836_MBOX_WRITE_OFFSET 0x00000020
|
||||
+
|
||||
+#define BCM2836_MBOX_STATUS_FULL 0x1f
|
||||
+#define BCM2836_MBOX_STATUS_EMPTY 0x1e
|
||||
+
|
||||
+#define BCM2836_MBOX_NUM_CHANNELS 16
|
||||
+
|
||||
+#endif /* __BCM2836_MBOX_H__ */
|
||||
--
|
||||
2.51.2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
From a9b9b0912a84e57d91285b29ce3eb8823e1d053d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Tue, 12 Dec 2023 03:12:12 +0200
|
||||
Subject: [PATCH 04/16] Platform/RaspberryPi: Fix framebuffer base translation
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
On RPi 5, the firmware already returns a CPU address to the framebuffer.
|
||||
We need to mask off the VC bus alias so that it's only subtracted when
|
||||
present.
|
||||
|
||||
Display now works, with a few caveats:
|
||||
- the depth does not update from 16 to 32-bit anymore. It's necessary
|
||||
to add "framebuffer_depth=32" in config.txt.
|
||||
|
||||
- no resolutions higher than 1080p.
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
index 91f581ef..9077f077 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
@@ -754,7 +754,7 @@ RpiFirmwareAllocFb (
|
||||
}
|
||||
|
||||
*Pitch = Cmd->Pitch.Pitch;
|
||||
- *FbBase = Cmd->AllocFb.AlignmentBase - PcdGet64 (PcdDmaDeviceOffset);
|
||||
+ *FbBase = Cmd->AllocFb.AlignmentBase & ~PcdGet64 (PcdDmaDeviceOffset);
|
||||
*FbSize = Cmd->AllocFb.Size;
|
||||
ReleaseSpinLock (&mMailboxLock);
|
||||
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,535 @@
|
||||
From 512184f1a74ada3414d865b9a8356531a4fdb70f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 29 Dec 2023 02:56:03 +0200
|
||||
Subject: [PATCH 05/16] Platform/RPi5: Add RP1 USB support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Requires "pciex4_reset=0" in config.txt so that PCIe 2 is left
|
||||
configured by the VPU firmware, until we add our own host bridge
|
||||
driver.
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 13 ++
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 6 +
|
||||
.../Drivers/Rp1BusDxe/Rp1BusDxe.c | 98 +++++++++
|
||||
.../Drivers/Rp1BusDxe/Rp1BusDxe.inf | 39 ++++
|
||||
.../RaspberryPi/RpiSiliconPkg/Include/Rp1.asi | 60 ++++++
|
||||
.../RaspberryPi/RpiSiliconPkg/Include/Rp1.h | 191 ++++++++++++++++++
|
||||
.../RpiSiliconPkg/RpiSiliconPkg.dec | 22 ++
|
||||
7 files changed, 429 insertions(+)
|
||||
create mode 100644 Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.c
|
||||
create mode 100644 Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.inf
|
||||
create mode 100644 Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.asi
|
||||
create mode 100644 Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.h
|
||||
create mode 100644 Silicon/RaspberryPi/RpiSiliconPkg/RpiSiliconPkg.dec
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 79aa4f1b..6850203e 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -186,6 +186,8 @@
|
||||
BoardInfoLib|Platform/RaspberryPi/Library/BoardInfoLib/BoardInfoLib.inf
|
||||
BoardRevisionHelperLib|Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.inf
|
||||
|
||||
+ NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf
|
||||
+
|
||||
[LibraryClasses.common.SEC]
|
||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
|
||||
@@ -434,6 +436,11 @@
|
||||
#
|
||||
gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress|0x107c013880
|
||||
|
||||
+ #
|
||||
+ # RP1 BAR1 preconfigured by the VPU
|
||||
+ #
|
||||
+ gRpiSiliconTokenSpaceGuid.Rp1PciPeripheralsBar|0x1f00000000
|
||||
+
|
||||
## Default Terminal Type
|
||||
## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
|
||||
@@ -634,12 +641,18 @@
|
||||
ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf
|
||||
# MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
|
||||
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
|
||||
+ MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
|
||||
EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.inf {
|
||||
<PcdsFixedAtBuild>
|
||||
gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000
|
||||
gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xbfffffff
|
||||
}
|
||||
|
||||
+ #
|
||||
+ # RP1 I/O bridge
|
||||
+ #
|
||||
+ Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.inf
|
||||
+
|
||||
#
|
||||
# NVMe boot devices
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 8391c195..8cd67254 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -281,8 +281,14 @@ READ_LOCK_STATUS = TRUE
|
||||
INF ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf
|
||||
# INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
|
||||
INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
|
||||
+ INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
|
||||
INF EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.inf
|
||||
|
||||
+ #
|
||||
+ # RP1 I/O bridge
|
||||
+ #
|
||||
+ INF Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.inf
|
||||
+
|
||||
#
|
||||
# NVMe boot devices
|
||||
#
|
||||
diff --git a/Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.c b/Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.c
|
||||
new file mode 100644
|
||||
index 00000000..7d7012b5
|
||||
--- /dev/null
|
||||
+++ b/Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.c
|
||||
@@ -0,0 +1,98 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <Uefi.h>
|
||||
+#include <Library/DebugLib.h>
|
||||
+#include <Library/IoLib.h>
|
||||
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
|
||||
+
|
||||
+#include <Rp1.h>
|
||||
+
|
||||
+typedef struct {
|
||||
+ EFI_PHYSICAL_ADDRESS Bar;
|
||||
+ UINT32 ChipId;
|
||||
+} RP1_DEVICE;
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+Rp1RegisterDwc3Controllers (
|
||||
+ IN RP1_DEVICE *This
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ UINTN Index;
|
||||
+ EFI_PHYSICAL_ADDRESS FullBase;
|
||||
+
|
||||
+ EFI_PHYSICAL_ADDRESS Dwc3Addresses[] = {
|
||||
+ RP1_USBHOST0_BASE, RP1_USBHOST1_BASE
|
||||
+ };
|
||||
+
|
||||
+ for (Index = 0; Index < ARRAY_SIZE (Dwc3Addresses); Index++) {
|
||||
+ FullBase = This->Bar + Dwc3Addresses[Index];
|
||||
+ Status = RegisterNonDiscoverableMmioDevice (
|
||||
+ NonDiscoverableDeviceTypeXhci,
|
||||
+ NonDiscoverableDeviceDmaTypeNonCoherent,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ 1,
|
||||
+ FullBase,
|
||||
+ RP1_USBHOST_SIZE
|
||||
+ );
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR,
|
||||
+ "%a: Failed to register DWC3 controller at 0x%lx. Status=%r\n",
|
||||
+ __func__, FullBase, Status));
|
||||
+ return Status;
|
||||
+ }
|
||||
+ }
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+Rp1RegisterDevices (
|
||||
+ IN RP1_DEVICE *This
|
||||
+ )
|
||||
+{
|
||||
+ Rp1RegisterDwc3Controllers (This);
|
||||
+}
|
||||
+
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+Rp1EnableInterrupts (
|
||||
+ IN RP1_DEVICE *This
|
||||
+ )
|
||||
+{
|
||||
+ MmioWrite32 (This->Bar + RP1_PCIE_REG_SET + RP1_PCIE_MSIX_CFG (RP1_INT_USBHOST0_0),
|
||||
+ RP1_PCIE_MSIX_CFG_ENABLE);
|
||||
+ MmioWrite32 (This->Bar + RP1_PCIE_REG_SET + RP1_PCIE_MSIX_CFG (RP1_INT_USBHOST1_0),
|
||||
+ RP1_PCIE_MSIX_CFG_ENABLE);
|
||||
+}
|
||||
+
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+Rp1BusDxeEntryPoint (
|
||||
+ IN EFI_HANDLE ImageHandle,
|
||||
+ IN EFI_SYSTEM_TABLE *SystemTable
|
||||
+ )
|
||||
+{
|
||||
+ RP1_DEVICE Dev;
|
||||
+ Dev.Bar = PcdGet64 (Rp1PciPeripheralsBar);
|
||||
+ Dev.ChipId = MmioRead32 (Dev.Bar + RP1_SYSINFO_BASE);
|
||||
+
|
||||
+ DEBUG ((DEBUG_INFO, "RP1 chip id: %x, peripheral BAR at CPU address 0x%lx\n",
|
||||
+ Dev.ChipId, Dev.Bar));
|
||||
+
|
||||
+ Rp1RegisterDevices (&Dev);
|
||||
+ Rp1EnableInterrupts (&Dev);
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
diff --git a/Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.inf b/Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.inf
|
||||
new file mode 100644
|
||||
index 00000000..ffc8c143
|
||||
--- /dev/null
|
||||
+++ b/Silicon/RaspberryPi/RpiSiliconPkg/Drivers/Rp1BusDxe/Rp1BusDxe.inf
|
||||
@@ -0,0 +1,39 @@
|
||||
+#/** @file
|
||||
+#
|
||||
+# Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+#
|
||||
+#**/
|
||||
+
|
||||
+[Defines]
|
||||
+ INF_VERSION = 0x0001001A
|
||||
+ BASE_NAME = Rp1BusDxe
|
||||
+ FILE_GUID = 7d4843f2-f474-40b1-87de-4d67fad8b00f
|
||||
+ MODULE_TYPE = DXE_DRIVER
|
||||
+ VERSION_STRING = 1.0
|
||||
+ ENTRY_POINT = Rp1BusDxeEntryPoint
|
||||
+
|
||||
+[Sources]
|
||||
+ Rp1BusDxe.c
|
||||
+
|
||||
+[Packages]
|
||||
+ MdePkg/MdePkg.dec
|
||||
+ MdeModulePkg/MdeModulePkg.dec
|
||||
+ Silicon/RaspberryPi/RpiSiliconPkg/RpiSiliconPkg.dec
|
||||
+
|
||||
+[LibraryClasses]
|
||||
+ DebugLib
|
||||
+ IoLib
|
||||
+ NonDiscoverableDeviceRegistrationLib
|
||||
+ UefiBootServicesTableLib
|
||||
+ UefiDriverEntryPoint
|
||||
+ UefiLib
|
||||
+
|
||||
+[Protocols]
|
||||
+
|
||||
+[Pcd]
|
||||
+ gRpiSiliconTokenSpaceGuid.Rp1PciPeripheralsBar
|
||||
+
|
||||
+[Depex]
|
||||
+ TRUE
|
||||
diff --git a/Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.asi b/Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.asi
|
||||
new file mode 100644
|
||||
index 00000000..9de562ba
|
||||
--- /dev/null
|
||||
+++ b/Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.asi
|
||||
@@ -0,0 +1,60 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <Rp1.h>
|
||||
+
|
||||
+#define RP1_QWORDMEMORY_BUF(Index) \
|
||||
+ QWordMemory (ResourceConsumer,, \
|
||||
+ MinFixed, MaxFixed, NonCacheable, ReadWrite, \
|
||||
+ 0x0, 0x0, 0x0, 0x0, 0x1,,, RB ## Index)
|
||||
+
|
||||
+#define RP1_QWORDMEMORY_SET(Index, Offset, Length) \
|
||||
+ CreateQwordField (RBUF, RB ## Index._MIN, MI ## Index) \
|
||||
+ CreateQwordField (RBUF, RB ## Index._MAX, MA ## Index) \
|
||||
+ CreateQwordField (RBUF, RB ## Index._LEN, LE ## Index) \
|
||||
+ LE ## Index = Length \
|
||||
+ MI ## Index = PBAR + Offset \
|
||||
+ MA ## Index = MI ## Index + LE ## Index - 1
|
||||
+
|
||||
+#define RP1_INTERRUPT_BUF(Index) \
|
||||
+ Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,,, \
|
||||
+ RB ## Index) { 0 } \
|
||||
+
|
||||
+#define RP1_INTERRUPT_SET(Index) \
|
||||
+ CreateDwordField (RBUF, RB ## Index._INT, IN ## Index) \
|
||||
+ IN ## Index = PINT
|
||||
+
|
||||
+Device (XHC0) {
|
||||
+ Name (_HID, "PNP0D10")
|
||||
+ Name (_UID, 0x0)
|
||||
+
|
||||
+ Method (_CRS, 0, Serialized) {
|
||||
+ Name (RBUF, ResourceTemplate () {
|
||||
+ RP1_QWORDMEMORY_BUF (00)
|
||||
+ RP1_INTERRUPT_BUF (01)
|
||||
+ })
|
||||
+ RP1_QWORDMEMORY_SET (00, RP1_USBHOST0_BASE, RP1_USBHOST_SIZE)
|
||||
+ RP1_INTERRUPT_SET (01)
|
||||
+ Return (RBUF)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+Device (XHC1) {
|
||||
+ Name (_HID, "PNP0D10")
|
||||
+ Name (_UID, 0x1)
|
||||
+
|
||||
+ Method (_CRS, 0, Serialized) {
|
||||
+ Name (RBUF, ResourceTemplate () {
|
||||
+ RP1_QWORDMEMORY_BUF (00)
|
||||
+ RP1_INTERRUPT_BUF (01)
|
||||
+ })
|
||||
+ RP1_QWORDMEMORY_SET (00, RP1_USBHOST1_BASE, RP1_USBHOST_SIZE)
|
||||
+ RP1_INTERRUPT_SET (01)
|
||||
+ Return (RBUF)
|
||||
+ }
|
||||
+}
|
||||
diff --git a/Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.h b/Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.h
|
||||
new file mode 100644
|
||||
index 00000000..13a33fc6
|
||||
--- /dev/null
|
||||
+++ b/Silicon/RaspberryPi/RpiSiliconPkg/Include/Rp1.h
|
||||
@@ -0,0 +1,191 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#ifndef __RP1_H__
|
||||
+#define __RP1_H__
|
||||
+
|
||||
+//
|
||||
+// BAR1 Peripherals
|
||||
+//
|
||||
+#define RP1_SYSINFO_BASE 0x00000000
|
||||
+#define RP1_SYSCFG_BASE 0x00008000
|
||||
+#define RP1_OTP_BASE 0x0000c000
|
||||
+#define RP1_POWER_BASE 0x00010000
|
||||
+#define RP1_RESETS_BASE 0x00014000
|
||||
+#define RP1_CLOCKS_MAIN_BASE 0x00018000
|
||||
+#define RP1_CLOCKS_VIDEO_BASE 0x0001c000
|
||||
+#define RP1_PLL_SYS_BASE 0x00020000
|
||||
+#define RP1_PLL_AUDIO_BASE 0x00024000
|
||||
+#define RP1_PLL_VIDEO_BASE 0x00028000
|
||||
+#define RP1_UART0_BASE 0x00030000
|
||||
+#define RP1_UART1_BASE 0x00034000
|
||||
+#define RP1_UART2_BASE 0x00038000
|
||||
+#define RP1_UART3_BASE 0x0003c000
|
||||
+#define RP1_UART4_BASE 0x00040000
|
||||
+#define RP1_UART5_BASE 0x00044000
|
||||
+#define RP1_SPI8_BASE 0x0004c000
|
||||
+#define RP1_SPI0_BASE 0x00050000
|
||||
+#define RP1_SPI1_BASE 0x00054000
|
||||
+#define RP1_SPI2_BASE 0x00058000
|
||||
+#define RP1_SPI3_BASE 0x0005c000
|
||||
+#define RP1_SPI4_BASE 0x00060000
|
||||
+#define RP1_SPI5_BASE 0x00064000
|
||||
+#define RP1_SPI6_BASE 0x00068000
|
||||
+#define RP1_SPI7_BASE 0x0006c000
|
||||
+#define RP1_I2C0_BASE 0x00070000
|
||||
+#define RP1_I2C1_BASE 0x00074000
|
||||
+#define RP1_I2C2_BASE 0x00078000
|
||||
+#define RP1_I2C3_BASE 0x0007c000
|
||||
+#define RP1_I2C4_BASE 0x00080000
|
||||
+#define RP1_I2C5_BASE 0x00084000
|
||||
+#define RP1_I2C6_BASE 0x00088000
|
||||
+#define RP1_AUDIO_IN_BASE 0x00090000
|
||||
+#define RP1_AUDIO_OUT_BASE 0x00094000
|
||||
+#define RP1_PWM0_BASE 0x00098000
|
||||
+#define RP1_PWM1_BASE 0x0009c000
|
||||
+#define RP1_I2S0_BASE 0x000a0000
|
||||
+#define RP1_I2S1_BASE 0x000a4000
|
||||
+#define RP1_I2S2_BASE 0x000a8000
|
||||
+#define RP1_TIMER_BASE 0x000ac000
|
||||
+#define RP1_SDIO0_CFG_BASE 0x000b0000
|
||||
+#define RP1_SDIO1_CFG_BASE 0x000b4000
|
||||
+#define RP1_BUSFABRIC_MONITOR_BASE 0x000c0000
|
||||
+#define RP1_BUSFABRIC_AXISHIM_BASE 0x000c4000
|
||||
+#define RP1_ADC_BASE 0x000c8000
|
||||
+#define RP1_IO_BANK0_BASE 0x000d0000
|
||||
+#define RP1_IO_BANK1_BASE 0x000d4000
|
||||
+#define RP1_IO_BANK2_BASE 0x000d8000
|
||||
+#define RP1_SYS_RIO0_BASE 0x000e0000
|
||||
+#define RP1_SYS_RIO1_BASE 0x000e4000
|
||||
+#define RP1_SYS_RIO2_BASE 0x000e8000
|
||||
+#define RP1_PADS_BANK0_BASE 0x000f0000
|
||||
+#define RP1_PADS_BANK1_BASE 0x000f4000
|
||||
+#define RP1_PADS_BANK2_BASE 0x000f8000
|
||||
+#define RP1_PADS_ETH_BASE 0x000fc000
|
||||
+#define RP1_ETH_BASE 0x00100000
|
||||
+#define RP1_ETH_CFG_BASE 0x00104000
|
||||
+#define RP1_PCIE_BASE 0x00108000
|
||||
+#define RP1_MIPI0_CSIDMA_BASE 0x00110000
|
||||
+#define RP1_MIPI0_CSIHOST_BASE 0x00114000
|
||||
+#define RP1_MIPI0_DSIDMA_BASE 0x00118000
|
||||
+#define RP1_MIPI0_DSIHOST_BASE 0x0011c000
|
||||
+#define RP1_MIPI0_CFG_BASE 0x00120000
|
||||
+#define RP1_MIPI0_ISP_BASE 0x00124000
|
||||
+#define RP1_MIPI1_CSIDMA_BASE 0x00128000
|
||||
+#define RP1_MIPI1_CSIHOST_BASE 0x0012c000
|
||||
+#define RP1_MIPI1_DSIDMA_BASE 0x00130000
|
||||
+#define RP1_MIPI1_DSIHOST_BASE 0x00134000
|
||||
+#define RP1_MIPI1_CFG_BASE 0x00138000
|
||||
+#define RP1_MIPI1_ISP_BASE 0x0013c000
|
||||
+#define RP1_VIDEO_OUT_CFG_BASE 0x00140000
|
||||
+#define RP1_VIDEO_OUT_VEC_BASE 0x00144000
|
||||
+#define RP1_VIDEO_OUT_DPI_BASE 0x00148000
|
||||
+#define RP1_XOSC_BASE 0x00150000
|
||||
+#define RP1_WATCHDOG_BASE 0x00154000
|
||||
+#define RP1_DMA_TICK_BASE 0x00158000
|
||||
+#define RP1_USBHOST0_CFG_BASE 0x00160000
|
||||
+#define RP1_USBHOST1_CFG_BASE 0x00164000
|
||||
+#define RP1_ROSC0_BASE 0x00168000
|
||||
+#define RP1_ROSC1_BASE 0x0016c000
|
||||
+#define RP1_VBUSCTRL_BASE 0x00170000
|
||||
+#define RP1_TICKS_BASE 0x00174000
|
||||
+#define RP1_PIO_BASE 0x00178000
|
||||
+#define RP1_SDIO0_BASE 0x00180000
|
||||
+#define RP1_SDIO1_BASE 0x00184000
|
||||
+#define RP1_DMA_BASE 0x00188000
|
||||
+#define RP1_USBHOST0_BASE 0x00200000
|
||||
+#define RP1_USBHOST1_BASE 0x00300000
|
||||
+#define RP1_EXAC_BASE 0x00400000
|
||||
+
|
||||
+#define RP1_USBHOST_SIZE 0x00100000
|
||||
+
|
||||
+//
|
||||
+// Local MSI-X vectors
|
||||
+//
|
||||
+#define RP1_INT_IO_BANK0 0
|
||||
+#define RP1_INT_IO_BANK1 1
|
||||
+#define RP1_INT_IO_BANK2 2
|
||||
+#define RP1_INT_AUDIO_IN 3
|
||||
+#define RP1_INT_AUDIO_OUT 4
|
||||
+#define RP1_INT_PWM0 5
|
||||
+#define RP1_INT_ETH 6
|
||||
+#define RP1_INT_I2C0 7
|
||||
+#define RP1_INT_I2C1 8
|
||||
+#define RP1_INT_I2C2 9
|
||||
+#define RP1_INT_I2C3 10
|
||||
+#define RP1_INT_I2C4 11
|
||||
+#define RP1_INT_I2C5 12
|
||||
+#define RP1_INT_I2C6 13
|
||||
+#define RP1_INT_I2S0 14
|
||||
+#define RP1_INT_I2S1 15
|
||||
+#define RP1_INT_I2S2 16
|
||||
+#define RP1_INT_SDIO0 17
|
||||
+#define RP1_INT_SDIO1 18
|
||||
+#define RP1_INT_SPI0 19
|
||||
+#define RP1_INT_SPI1 20
|
||||
+#define RP1_INT_SPI2 21
|
||||
+#define RP1_INT_SPI3 22
|
||||
+#define RP1_INT_SPI4 23
|
||||
+#define RP1_INT_SPI5 24
|
||||
+#define RP1_INT_UART0 25
|
||||
+#define RP1_INT_TIMER_0 26
|
||||
+#define RP1_INT_TIMER_1 27
|
||||
+#define RP1_INT_TIMER_2 28
|
||||
+#define RP1_INT_TIMER_3 29
|
||||
+#define RP1_INT_USBHOST0 30
|
||||
+#define RP1_INT_USBHOST0_0 31
|
||||
+#define RP1_INT_USBHOST0_1 32
|
||||
+#define RP1_INT_USBHOST0_2 33
|
||||
+#define RP1_INT_USBHOST0_3 34
|
||||
+#define RP1_INT_USBHOST1 35
|
||||
+#define RP1_INT_USBHOST1_0 36
|
||||
+#define RP1_INT_USBHOST1_1 37
|
||||
+#define RP1_INT_USBHOST1_2 38
|
||||
+#define RP1_INT_USBHOST1_3 39
|
||||
+#define RP1_INT_DMA 40
|
||||
+#define RP1_INT_PWM1 41
|
||||
+#define RP1_INT_UART1 42
|
||||
+#define RP1_INT_UART2 43
|
||||
+#define RP1_INT_UART3 44
|
||||
+#define RP1_INT_UART4 45
|
||||
+#define RP1_INT_UART5 46
|
||||
+#define RP1_INT_MIPI0 47
|
||||
+#define RP1_INT_MIPI1 48
|
||||
+#define RP1_INT_VIDEO_OUT 49
|
||||
+#define RP1_INT_PIO_0 50
|
||||
+#define RP1_INT_PIO_1 51
|
||||
+#define RP1_INT_ADC_FIFO 52
|
||||
+#define RP1_INT_PCIE_OUT 53
|
||||
+#define RP1_INT_SPI6 54
|
||||
+#define RP1_INT_SPI7 55
|
||||
+#define RP1_INT_SPI8 56
|
||||
+#define RP1_INT_PROC_MISC 57
|
||||
+#define RP1_INT_SYSCFG 58
|
||||
+#define RP1_INT_CLOCKS_DEFAULT 59
|
||||
+#define RP1_INT_VBUSCTRL 60
|
||||
+
|
||||
+//
|
||||
+// System information registers
|
||||
+//
|
||||
+#define RP1_SYSINFO_CHIP_ID 0x0
|
||||
+
|
||||
+//
|
||||
+// PCIe endpoint configuration registers
|
||||
+//
|
||||
+#define RP1_PCIE_REG_RW (RP1_PCIE_BASE + 0x000)
|
||||
+#define RP1_PCIE_REG_SET (RP1_PCIE_BASE + 0x800)
|
||||
+#define RP1_PCIE_REG_CLR (RP1_PCIE_BASE + 0xc00)
|
||||
+
|
||||
+// MSI-X vectors configuration
|
||||
+#define RP1_PCIE_MSIX_CFG(Irq) (0x008 + ((Irq) * 4))
|
||||
+#define RP1_PCIE_MSIX_CFG_IACK_EN BIT3
|
||||
+#define RP1_PCIE_MSIX_CFG_IACK BIT2
|
||||
+#define RP1_PCIE_MSIX_CFG_TEST BIT1
|
||||
+#define RP1_PCIE_MSIX_CFG_ENABLE BIT0
|
||||
+
|
||||
+#endif // __RP1_H__
|
||||
diff --git a/Silicon/RaspberryPi/RpiSiliconPkg/RpiSiliconPkg.dec b/Silicon/RaspberryPi/RpiSiliconPkg/RpiSiliconPkg.dec
|
||||
new file mode 100644
|
||||
index 00000000..d66041e0
|
||||
--- /dev/null
|
||||
+++ b/Silicon/RaspberryPi/RpiSiliconPkg/RpiSiliconPkg.dec
|
||||
@@ -0,0 +1,22 @@
|
||||
+#/** @file
|
||||
+#
|
||||
+# Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+#
|
||||
+#**/
|
||||
+
|
||||
+[Defines]
|
||||
+ DEC_SPECIFICATION = 0x0001001A
|
||||
+ PACKAGE_NAME = RpiSiliconPkg
|
||||
+ PACKAGE_GUID = 6dd4364e-9b8a-449e-b0a7-60095c5a0f15
|
||||
+ PACKAGE_VERSION = 1.0
|
||||
+
|
||||
+[Includes]
|
||||
+ Include
|
||||
+
|
||||
+[Guids]
|
||||
+ gRpiSiliconTokenSpaceGuid = { 0x0b3ce57a, 0xa82b, 0x4ada, { 0x8f, 0xb5, 0x52, 0xc8, 0x72, 0x30, 0x1f, 0xdb } }
|
||||
+
|
||||
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
|
||||
+ gRpiSiliconTokenSpaceGuid.Rp1PciPeripheralsBar|0x0|UINT64|0x00000001
|
||||
--
|
||||
2.51.2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,766 @@
|
||||
From 8f06d1faaae5fcd2773ddf7e003f252f601406c4 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 29 Dec 2023 05:40:21 +0200
|
||||
Subject: [PATCH 07/16] Platform/RPi5: Add SDHCI support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Also configure SDIO Wi-Fi for later.
|
||||
|
||||
Depends on the SdMmcPciHcDxe patch in EDK2 for external 1.8v signaling
|
||||
switch.
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
.../RPi5/Drivers/RpiPlatformDxe/Peripherals.c | 104 ++++++++
|
||||
.../RPi5/Drivers/RpiPlatformDxe/Peripherals.h | 18 ++
|
||||
.../Drivers/RpiPlatformDxe/RpiPlatformDxe.c | 23 ++
|
||||
.../Drivers/RpiPlatformDxe/RpiPlatformDxe.inf | 40 ++++
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 13 +-
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 10 +-
|
||||
.../Include/IndustryStandard/Bcm2712.h | 7 +
|
||||
Silicon/Broadcom/BroadcomPkg.dec | 22 ++
|
||||
.../Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.c | 224 ++++++++++++++++++
|
||||
.../Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.h | 62 +++++
|
||||
.../BrcmStbSdhciDxe/BrcmStbSdhciDxe.inf | 39 +++
|
||||
.../Include/Protocol/BrcmStbSdhciDevice.h | 47 ++++
|
||||
12 files changed, 606 insertions(+), 3 deletions(-)
|
||||
create mode 100644 Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.c
|
||||
create mode 100644 Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.h
|
||||
create mode 100644 Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.c
|
||||
create mode 100644 Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
create mode 100644 Silicon/Broadcom/BroadcomPkg.dec
|
||||
create mode 100644 Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.c
|
||||
create mode 100644 Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.h
|
||||
create mode 100644 Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.inf
|
||||
create mode 100644 Silicon/Broadcom/Include/Protocol/BrcmStbSdhciDevice.h
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.c b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.c
|
||||
new file mode 100644
|
||||
index 00000000..7cb08635
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.c
|
||||
@@ -0,0 +1,104 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <Uefi.h>
|
||||
+#include <IndustryStandard/Bcm2712.h>
|
||||
+#include <IndustryStandard/Bcm2712Pinctrl.h>
|
||||
+#include <Library/Bcm2712GpioLib.h>
|
||||
+#include <Library/DebugLib.h>
|
||||
+#include <Library/UefiBootServicesTableLib.h>
|
||||
+#include <Protocol/BrcmStbSdhciDevice.h>
|
||||
+
|
||||
+#include "Peripherals.h"
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+SdControllerSetSignalingVoltage (
|
||||
+ IN BRCMSTB_SDHCI_DEVICE_PROTOCOL *This,
|
||||
+ IN SD_MMC_SIGNALING_VOLTAGE Voltage
|
||||
+ )
|
||||
+{
|
||||
+ // sd_io_1v8_reg
|
||||
+ GpioWrite (BCM2712_GIO_AON, 3, Voltage == SdMmcSignalingVoltage18);
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+STATIC BRCMSTB_SDHCI_DEVICE_PROTOCOL mSdController = {
|
||||
+ .HostAddress = BCM2712_BRCMSTB_SDIO1_HOST_BASE,
|
||||
+ .CfgAddress = BCM2712_BRCMSTB_SDIO1_CFG_BASE,
|
||||
+ .DmaType = NonDiscoverableDeviceDmaTypeNonCoherent,
|
||||
+ .IsSlotRemovable = TRUE,
|
||||
+ .SetSignalingVoltage = SdControllerSetSignalingVoltage
|
||||
+};
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+RegisterSdControllers (
|
||||
+ VOID
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ EFI_HANDLE Handle = NULL;
|
||||
+
|
||||
+ Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
+ &Handle,
|
||||
+ &gBrcmStbSdhciDeviceProtocolGuid,
|
||||
+ &mSdController,
|
||||
+ NULL);
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+
|
||||
+ return Status;
|
||||
+}
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+InitGpioPinctrls (
|
||||
+ VOID
|
||||
+ )
|
||||
+{
|
||||
+ // SD card detect
|
||||
+ GpioSetFunction (BCM2712_GIO_AON, 5, GIO_AON_PIN5_ALT_SD_CARD_G);
|
||||
+ GpioSetPull (BCM2712_GIO_AON, 5, BCM2712_GPIO_PIN_PULL_UP);
|
||||
+
|
||||
+ // Route SDIO to Wi-Fi
|
||||
+ GpioSetFunction (BCM2712_GIO, 30, GIO_PIN30_ALT_SD2);
|
||||
+ GpioSetPull (BCM2712_GIO, 30, BCM2712_GPIO_PIN_PULL_NONE);
|
||||
+ GpioSetFunction (BCM2712_GIO, 31, GIO_PIN31_ALT_SD2);
|
||||
+ GpioSetPull (BCM2712_GIO, 31, BCM2712_GPIO_PIN_PULL_UP);
|
||||
+ GpioSetFunction (BCM2712_GIO, 32, GIO_PIN32_ALT_SD2);
|
||||
+ GpioSetPull (BCM2712_GIO, 32, BCM2712_GPIO_PIN_PULL_UP);
|
||||
+ GpioSetFunction (BCM2712_GIO, 33, GIO_PIN33_ALT_SD2);
|
||||
+ GpioSetPull (BCM2712_GIO, 33, BCM2712_GPIO_PIN_PULL_UP);
|
||||
+ GpioSetFunction (BCM2712_GIO, 34, GIO_PIN34_ALT_SD2);
|
||||
+ GpioSetPull (BCM2712_GIO, 34, BCM2712_GPIO_PIN_PULL_UP);
|
||||
+ GpioSetFunction (BCM2712_GIO, 35, GIO_PIN35_ALT_SD2);
|
||||
+ GpioSetPull (BCM2712_GIO, 35, BCM2712_GPIO_PIN_PULL_UP);
|
||||
+
|
||||
+ // wl_on_reg
|
||||
+ GpioWrite (BCM2712_GIO, 28, TRUE);
|
||||
+ GpioSetDirection (BCM2712_GIO, 28, BCM2712_GPIO_PIN_OUTPUT);
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+SetupPeripherals (
|
||||
+ VOID
|
||||
+ )
|
||||
+{
|
||||
+ InitGpioPinctrls ();
|
||||
+
|
||||
+ RegisterSdControllers ();
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.h b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.h
|
||||
new file mode 100644
|
||||
index 00000000..ef74a44d
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/Peripherals.h
|
||||
@@ -0,0 +1,18 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#ifndef __RPI_PLATFORM_PERIPHERALS_H__
|
||||
+#define __RPI_PLATFORM_PERIPHERALS_H__
|
||||
+
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+SetupPeripherals (
|
||||
+ VOID
|
||||
+ );
|
||||
+
|
||||
+#endif // __RPI_PLATFORM_PERIPHERALS_H__
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.c b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.c
|
||||
new file mode 100644
|
||||
index 00000000..5d993266
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.c
|
||||
@@ -0,0 +1,23 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <Uefi.h>
|
||||
+
|
||||
+#include "Peripherals.h"
|
||||
+
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+RpiPlatformDxeEntryPoint (
|
||||
+ IN EFI_HANDLE ImageHandle,
|
||||
+ IN EFI_SYSTEM_TABLE *SystemTable
|
||||
+ )
|
||||
+{
|
||||
+ SetupPeripherals ();
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
new file mode 100644
|
||||
index 00000000..7292ca30
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
@@ -0,0 +1,40 @@
|
||||
+#/** @file
|
||||
+#
|
||||
+# Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+#
|
||||
+#**/
|
||||
+
|
||||
+[Defines]
|
||||
+ INF_VERSION = 0x0001001A
|
||||
+ BASE_NAME = RpiPlatformDxe
|
||||
+ FILE_GUID = f6490266-0e7f-492e-8e15-ac69c1b7708a
|
||||
+ MODULE_TYPE = DXE_DRIVER
|
||||
+ VERSION_STRING = 1.0
|
||||
+ ENTRY_POINT = RpiPlatformDxeEntryPoint
|
||||
+
|
||||
+[Sources]
|
||||
+ RpiPlatformDxe.c
|
||||
+ Peripherals.c
|
||||
+
|
||||
+[Packages]
|
||||
+ MdePkg/MdePkg.dec
|
||||
+ MdeModulePkg/MdeModulePkg.dec
|
||||
+ EmbeddedPkg/EmbeddedPkg.dec
|
||||
+ Platform/RaspberryPi/RaspberryPi.dec
|
||||
+ Silicon/Broadcom/BroadcomPkg.dec
|
||||
+ Silicon/Broadcom/Bcm27xx/Bcm27xx.dec
|
||||
+
|
||||
+[LibraryClasses]
|
||||
+ DebugLib
|
||||
+ UefiLib
|
||||
+ UefiBootServicesTableLib
|
||||
+ UefiDriverEntryPoint
|
||||
+ Bcm2712GpioLib
|
||||
+
|
||||
+[Protocols]
|
||||
+ gBrcmStbSdhciDeviceProtocolGuid ## PRODUCES
|
||||
+
|
||||
+[Depex]
|
||||
+ TRUE
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 6850203e..0a97e317 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -180,7 +180,6 @@
|
||||
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
- GpioLib|Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf
|
||||
|
||||
FdtPlatformLib|Platform/RaspberryPi/Library/FdtPlatformLib/FdtPlatformLib.inf
|
||||
BoardInfoLib|Platform/RaspberryPi/Library/BoardInfoLib/BoardInfoLib.inf
|
||||
@@ -188,6 +187,8 @@
|
||||
|
||||
NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf
|
||||
|
||||
+ Bcm2712GpioLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2712GpioLib/Bcm2712GpioLib.inf
|
||||
+
|
||||
[LibraryClasses.common.SEC]
|
||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
|
||||
@@ -561,8 +562,8 @@
|
||||
|
||||
ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
|
||||
Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
+ Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
# Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
- # Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
|
||||
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
|
||||
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
|
||||
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
|
||||
@@ -625,6 +626,14 @@
|
||||
MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
|
||||
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
|
||||
|
||||
+ #
|
||||
+ # SD/eMMC Support
|
||||
+ #
|
||||
+ MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf
|
||||
+ MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
|
||||
+ MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf
|
||||
+ Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.inf
|
||||
+
|
||||
#
|
||||
# Networking stack
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 8cd67254..ba19551b 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -214,8 +214,8 @@ READ_LOCK_STATUS = TRUE
|
||||
|
||||
INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
|
||||
INF Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
+ INF Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
# INF Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
- # INF Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
|
||||
INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
|
||||
INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
|
||||
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
|
||||
@@ -308,6 +308,14 @@ READ_LOCK_STATUS = TRUE
|
||||
INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
|
||||
INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
|
||||
|
||||
+ #
|
||||
+ # SD/eMMC Support
|
||||
+ #
|
||||
+ INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf
|
||||
+ INF MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
|
||||
+ INF MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf
|
||||
+ INF Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.inf
|
||||
+
|
||||
#
|
||||
# Pi logo (splash screen)
|
||||
#
|
||||
diff --git a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2712.h b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2712.h
|
||||
index a0d3e850..c5365141 100644
|
||||
--- a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2712.h
|
||||
+++ b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2712.h
|
||||
@@ -19,4 +19,11 @@
|
||||
#define BCM2712_PINCTRL_AON_BASE 0x107d510700
|
||||
#define BCM2712_PINCTRL_AON_LENGTH 0x20
|
||||
|
||||
+#define BCM2712_BRCMSTB_SDIO1_HOST_BASE 0x1000fff000
|
||||
+#define BCM2712_BRCMSTB_SDIO1_CFG_BASE 0x1000fff400
|
||||
+#define BCM2712_BRCMSTB_SDIO2_HOST_BASE 0x1001100000
|
||||
+#define BCM2712_BRCMSTB_SDIO2_CFG_BASE 0x1001100400
|
||||
+#define BCM2712_BRCMSTB_SDIO_HOST_LENGTH 0x260
|
||||
+#define BCM2712_BRCMSTB_SDIO_CFG_LENGTH 0x200
|
||||
+
|
||||
#endif // __BCM2712_H__
|
||||
diff --git a/Silicon/Broadcom/BroadcomPkg.dec b/Silicon/Broadcom/BroadcomPkg.dec
|
||||
new file mode 100644
|
||||
index 00000000..31f876ae
|
||||
--- /dev/null
|
||||
+++ b/Silicon/Broadcom/BroadcomPkg.dec
|
||||
@@ -0,0 +1,22 @@
|
||||
+#/** @file
|
||||
+#
|
||||
+# Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+#
|
||||
+#**/
|
||||
+
|
||||
+[Defines]
|
||||
+ DEC_SPECIFICATION = 0x0001001A
|
||||
+ PACKAGE_NAME = BroadcomPkg
|
||||
+ PACKAGE_GUID = b25a0fef-f089-420f-98f2-adb9b9a34b18
|
||||
+ PACKAGE_VERSION = 1.0
|
||||
+
|
||||
+[Includes]
|
||||
+ Include
|
||||
+
|
||||
+[Guids]
|
||||
+ gBroadcomTokenSpaceGuid = { 0xe49c8829, 0xfd87, 0x40cd, { 0x99, 0xf4, 0x61, 0x08, 0x15, 0x92, 0x76, 0x4e } }
|
||||
+
|
||||
+[Protocols]
|
||||
+ gBrcmStbSdhciDeviceProtocolGuid = { 0xd6c196f9, 0x9c8c, 0x448f, { 0xbd, 0x21, 0xd9, 0x76, 0xa8, 0x3a, 0x82, 0x7f } }
|
||||
diff --git a/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.c b/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.c
|
||||
new file mode 100644
|
||||
index 00000000..80e30a2d
|
||||
--- /dev/null
|
||||
+++ b/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.c
|
||||
@@ -0,0 +1,224 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <Library/DebugLib.h>
|
||||
+#include <Library/IoLib.h>
|
||||
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
|
||||
+#include <Library/UefiLib.h>
|
||||
+#include <Library/UefiBootServicesTableLib.h>
|
||||
+
|
||||
+#include <Protocol/BrcmStbSdhciDevice.h>
|
||||
+#include <Protocol/NonDiscoverableDevice.h>
|
||||
+#include <Protocol/SdMmcOverride.h>
|
||||
+
|
||||
+#include "BrcmStbSdhciDxe.h"
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+SdMmcCapability (
|
||||
+ IN EFI_HANDLE ControllerHandle,
|
||||
+ IN UINT8 Slot,
|
||||
+ IN OUT VOID *SdMmcHcSlotCapability,
|
||||
+ IN OUT UINT32 *BaseClkFreq
|
||||
+ )
|
||||
+{
|
||||
+ SD_MMC_HC_SLOT_CAP *Capability;
|
||||
+
|
||||
+ if (Slot != 0) {
|
||||
+ return EFI_UNSUPPORTED;
|
||||
+ }
|
||||
+ if (SdMmcHcSlotCapability == NULL) {
|
||||
+ return EFI_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
+ Capability = SdMmcHcSlotCapability;
|
||||
+
|
||||
+ // Hardware retuning is not supported.
|
||||
+ Capability->RetuningMod = 0;
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+SdMmcNotifyPhase (
|
||||
+ IN EFI_HANDLE ControllerHandle,
|
||||
+ IN UINT8 Slot,
|
||||
+ IN EDKII_SD_MMC_PHASE_TYPE PhaseType,
|
||||
+ IN OUT VOID *PhaseData
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ BRCMSTB_SDHCI_DEVICE_PROTOCOL *Device;
|
||||
+
|
||||
+ if (Slot != 0) {
|
||||
+ return EFI_UNSUPPORTED;
|
||||
+ }
|
||||
+
|
||||
+ Status = gBS->HandleProtocol (
|
||||
+ ControllerHandle,
|
||||
+ &gBrcmStbSdhciDeviceProtocolGuid,
|
||||
+ (VOID **)&Device);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: Failed to get protocol. Status=%r\n",
|
||||
+ __func__, Status));
|
||||
+ return EFI_UNSUPPORTED;
|
||||
+ }
|
||||
+
|
||||
+ switch (PhaseType) {
|
||||
+ case EdkiiSdMmcSetSignalingVoltage:
|
||||
+ if (PhaseData == NULL) {
|
||||
+ return EFI_INVALID_PARAMETER;
|
||||
+ }
|
||||
+ if (Device->SetSignalingVoltage != NULL) {
|
||||
+ return Device->SetSignalingVoltage (Device, *(SD_MMC_SIGNALING_VOLTAGE *)PhaseData);
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+STATIC EDKII_SD_MMC_OVERRIDE mSdMmcOverride = {
|
||||
+ EDKII_SD_MMC_OVERRIDE_PROTOCOL_VERSION,
|
||||
+ SdMmcCapability,
|
||||
+ SdMmcNotifyPhase,
|
||||
+};
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+StartDevice (
|
||||
+ IN BRCMSTB_SDHCI_DEVICE_PROTOCOL *This,
|
||||
+ IN EFI_HANDLE ControllerHandle
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+
|
||||
+ //
|
||||
+ // Set the PHY DLL as clock source to support higher speed modes
|
||||
+ // reliably.
|
||||
+ //
|
||||
+ MmioAndThenOr32 (This->CfgAddress + SDIO_CFG_MAX_50MHZ_MODE,
|
||||
+ ~SDIO_CFG_MAX_50MHZ_MODE_ENABLE,
|
||||
+ SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE);
|
||||
+
|
||||
+ if (This->IsSlotRemovable) {
|
||||
+ MmioAndThenOr32 (This->CfgAddress + SDIO_CFG_SD_PIN_SEL,
|
||||
+ ~SDIO_CFG_SD_PIN_SEL_MASK,
|
||||
+ SDIO_CFG_SD_PIN_SEL_CARD);
|
||||
+ } else {
|
||||
+ MmioAndThenOr32 (This->CfgAddress + SDIO_CFG_CTRL,
|
||||
+ ~SDIO_CFG_CTRL_SDCD_N_TEST_LEV,
|
||||
+ SDIO_CFG_CTRL_SDCD_N_TEST_EN);
|
||||
+ }
|
||||
+
|
||||
+ Status = RegisterNonDiscoverableMmioDevice (
|
||||
+ NonDiscoverableDeviceTypeSdhci,
|
||||
+ This->DmaType,
|
||||
+ NULL,
|
||||
+ &ControllerHandle,
|
||||
+ 1,
|
||||
+ This->HostAddress, SDIO_HOST_SIZE);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR,
|
||||
+ "%a: Failed to register Broadcom STB SDHCI controller at 0x%lx. Status=%r\n",
|
||||
+ __func__, This->HostAddress, Status));
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ return Status;
|
||||
+}
|
||||
+
|
||||
+STATIC VOID *mProtocolInstallEventRegistration;
|
||||
+
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+NotifyProtocolInstall (
|
||||
+ IN EFI_EVENT Event,
|
||||
+ IN VOID *Context
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ EFI_HANDLE Handle;
|
||||
+ UINTN BufferSize;
|
||||
+ BRCMSTB_SDHCI_DEVICE_PROTOCOL *Device;
|
||||
+
|
||||
+ while (TRUE) {
|
||||
+ BufferSize = sizeof (EFI_HANDLE);
|
||||
+ Status = gBS->LocateHandle (
|
||||
+ ByRegisterNotify,
|
||||
+ NULL,
|
||||
+ mProtocolInstallEventRegistration,
|
||||
+ &BufferSize,
|
||||
+ &Handle);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ if (Status != EFI_NOT_FOUND) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: Failed to locate protocol. Status=%r\n",
|
||||
+ __func__, Status));
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ Status = gBS->HandleProtocol (
|
||||
+ Handle,
|
||||
+ &gBrcmStbSdhciDeviceProtocolGuid,
|
||||
+ (VOID **)&Device);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: Failed to get protocol. Status=%r\n",
|
||||
+ __func__, Status));
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ Status = StartDevice (Device, Handle);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: Failed to start device. Status=%r\n",
|
||||
+ __func__, Status));
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+BrcmStbSdhciDxeInitialize (
|
||||
+ IN EFI_HANDLE ImageHandle,
|
||||
+ IN EFI_SYSTEM_TABLE *SystemTable
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ EFI_HANDLE Handle;
|
||||
+ EFI_EVENT ProtocolInstallEvent;
|
||||
+
|
||||
+ ProtocolInstallEvent = EfiCreateProtocolNotifyEvent (
|
||||
+ &gBrcmStbSdhciDeviceProtocolGuid,
|
||||
+ TPL_CALLBACK,
|
||||
+ NotifyProtocolInstall,
|
||||
+ NULL,
|
||||
+ &mProtocolInstallEventRegistration);
|
||||
+ if (ProtocolInstallEvent == NULL) {
|
||||
+ ASSERT (FALSE);
|
||||
+ return EFI_OUT_OF_RESOURCES;
|
||||
+ }
|
||||
+
|
||||
+ Handle = NULL;
|
||||
+ Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
+ &Handle,
|
||||
+ &gEdkiiSdMmcOverrideProtocolGuid,
|
||||
+ &mSdMmcOverride,
|
||||
+ NULL);
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+
|
||||
+ return Status;
|
||||
+}
|
||||
diff --git a/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.h b/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.h
|
||||
new file mode 100644
|
||||
index 00000000..7ea854c1
|
||||
--- /dev/null
|
||||
+++ b/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.h
|
||||
@@ -0,0 +1,62 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#ifndef __BRCMSTB_SDHCI_DXE_H__
|
||||
+#define __BRCMSTB_SDHCI_DXE_H__
|
||||
+
|
||||
+#define SDIO_HOST_SIZE 0x260
|
||||
+
|
||||
+#define SDIO_CFG_CTRL 0x0
|
||||
+#define SDIO_CFG_CTRL_SDCD_N_TEST_EN BIT31
|
||||
+#define SDIO_CFG_CTRL_SDCD_N_TEST_LEV BIT30
|
||||
+
|
||||
+#define SDIO_CFG_SD_PIN_SEL 0x44
|
||||
+#define SDIO_CFG_SD_PIN_SEL_MASK (BIT1 | BIT0)
|
||||
+#define SDIO_CFG_SD_PIN_SEL_CARD BIT1
|
||||
+
|
||||
+#define SDIO_CFG_MAX_50MHZ_MODE 0x1ac
|
||||
+#define SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE BIT31
|
||||
+#define SDIO_CFG_MAX_50MHZ_MODE_ENABLE BIT0
|
||||
+
|
||||
+typedef struct {
|
||||
+ UINT32 TimeoutFreq : 6; // bit 0:5
|
||||
+ UINT32 Reserved : 1; // bit 6
|
||||
+ UINT32 TimeoutUnit : 1; // bit 7
|
||||
+ UINT32 BaseClkFreq : 8; // bit 8:15
|
||||
+ UINT32 MaxBlkLen : 2; // bit 16:17
|
||||
+ UINT32 BusWidth8 : 1; // bit 18
|
||||
+ UINT32 Adma2 : 1; // bit 19
|
||||
+ UINT32 Reserved2 : 1; // bit 20
|
||||
+ UINT32 HighSpeed : 1; // bit 21
|
||||
+ UINT32 Sdma : 1; // bit 22
|
||||
+ UINT32 SuspRes : 1; // bit 23
|
||||
+ UINT32 Voltage33 : 1; // bit 24
|
||||
+ UINT32 Voltage30 : 1; // bit 25
|
||||
+ UINT32 Voltage18 : 1; // bit 26
|
||||
+ UINT32 SysBus64V4 : 1; // bit 27
|
||||
+ UINT32 SysBus64V3 : 1; // bit 28
|
||||
+ UINT32 AsyncInt : 1; // bit 29
|
||||
+ UINT32 SlotType : 2; // bit 30:31
|
||||
+ UINT32 Sdr50 : 1; // bit 32
|
||||
+ UINT32 Sdr104 : 1; // bit 33
|
||||
+ UINT32 Ddr50 : 1; // bit 34
|
||||
+ UINT32 Reserved3 : 1; // bit 35
|
||||
+ UINT32 DriverTypeA : 1; // bit 36
|
||||
+ UINT32 DriverTypeC : 1; // bit 37
|
||||
+ UINT32 DriverTypeD : 1; // bit 38
|
||||
+ UINT32 DriverType4 : 1; // bit 39
|
||||
+ UINT32 TimerCount : 4; // bit 40:43
|
||||
+ UINT32 Reserved4 : 1; // bit 44
|
||||
+ UINT32 TuningSDR50 : 1; // bit 45
|
||||
+ UINT32 RetuningMod : 2; // bit 46:47
|
||||
+ UINT32 ClkMultiplier : 8; // bit 48:55
|
||||
+ UINT32 Reserved5 : 7; // bit 56:62
|
||||
+ UINT32 Hs400 : 1; // bit 63
|
||||
+} SD_MMC_HC_SLOT_CAP;
|
||||
+
|
||||
+#endif // __BRCMSTB_SDHCI_DXE_H__
|
||||
diff --git a/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.inf b/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.inf
|
||||
new file mode 100644
|
||||
index 00000000..9c513a3f
|
||||
--- /dev/null
|
||||
+++ b/Silicon/Broadcom/Drivers/BrcmStbSdhciDxe/BrcmStbSdhciDxe.inf
|
||||
@@ -0,0 +1,39 @@
|
||||
+#/** @file
|
||||
+#
|
||||
+# Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+#
|
||||
+#**/
|
||||
+
|
||||
+[Defines]
|
||||
+ INF_VERSION = 0x0001001A
|
||||
+ BASE_NAME = BrcmStbSdhciDxe
|
||||
+ FILE_GUID = d72a2469-f274-48e1-9bcb-3a28a2a09234
|
||||
+ MODULE_TYPE = DXE_DRIVER
|
||||
+ VERSION_STRING = 1.0
|
||||
+ ENTRY_POINT = BrcmStbSdhciDxeInitialize
|
||||
+
|
||||
+[Sources]
|
||||
+ BrcmStbSdhciDxe.c
|
||||
+
|
||||
+[Packages]
|
||||
+ MdePkg/MdePkg.dec
|
||||
+ MdeModulePkg/MdeModulePkg.dec
|
||||
+ Silicon/Broadcom/BroadcomPkg.dec
|
||||
+
|
||||
+[LibraryClasses]
|
||||
+ DebugLib
|
||||
+ IoLib
|
||||
+ NonDiscoverableDeviceRegistrationLib
|
||||
+ UefiLib
|
||||
+ UefiBootServicesTableLib
|
||||
+ UefiDriverEntryPoint
|
||||
+
|
||||
+[Protocols]
|
||||
+ gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES
|
||||
+ gEdkiiSdMmcOverrideProtocolGuid ## PRODUCES
|
||||
+ gBrcmStbSdhciDeviceProtocolGuid ## CONSUMES
|
||||
+
|
||||
+[Depex]
|
||||
+ TRUE
|
||||
diff --git a/Silicon/Broadcom/Include/Protocol/BrcmStbSdhciDevice.h b/Silicon/Broadcom/Include/Protocol/BrcmStbSdhciDevice.h
|
||||
new file mode 100644
|
||||
index 00000000..7837862c
|
||||
--- /dev/null
|
||||
+++ b/Silicon/Broadcom/Include/Protocol/BrcmStbSdhciDevice.h
|
||||
@@ -0,0 +1,47 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#ifndef __BRCMSTB_SDHCI_DEVICE_H__
|
||||
+#define __BRCMSTB_SDHCI_DEVICE_H__
|
||||
+
|
||||
+#include <Uefi/UefiBaseType.h>
|
||||
+#include <Protocol/NonDiscoverableDevice.h>
|
||||
+#include <Protocol/SdMmcOverride.h>
|
||||
+
|
||||
+#define BRCMSTB_SDHCI_DEVICE_PROTOCOL_GUID \
|
||||
+ { 0xd6c196f9, 0x9c8c, 0x448f, { 0xbd, 0x21, 0xd9, 0x76, 0xa8, 0x3a, 0x82, 0x7f } }
|
||||
+
|
||||
+typedef struct _BRCMSTB_SDHCI_DEVICE_PROTOCOL BRCMSTB_SDHCI_DEVICE_PROTOCOL;
|
||||
+
|
||||
+typedef
|
||||
+EFI_STATUS
|
||||
+(EFIAPI *BRCMSTB_SDHCI_SET_SIGNALING_VOLTAGE) (
|
||||
+ IN BRCMSTB_SDHCI_DEVICE_PROTOCOL *This,
|
||||
+ IN SD_MMC_SIGNALING_VOLTAGE Voltage
|
||||
+ );
|
||||
+
|
||||
+struct _BRCMSTB_SDHCI_DEVICE_PROTOCOL {
|
||||
+ //
|
||||
+ // Controller platform info
|
||||
+ //
|
||||
+ EFI_PHYSICAL_ADDRESS HostAddress;
|
||||
+ EFI_PHYSICAL_ADDRESS CfgAddress;
|
||||
+ NON_DISCOVERABLE_DEVICE_DMA_TYPE DmaType;
|
||||
+
|
||||
+ BOOLEAN IsSlotRemovable;
|
||||
+
|
||||
+ //
|
||||
+ // Optional callback for setting the signaling voltage via
|
||||
+ // an external regulator.
|
||||
+ //
|
||||
+ BRCMSTB_SDHCI_SET_SIGNALING_VOLTAGE SetSignalingVoltage;
|
||||
+};
|
||||
+
|
||||
+extern EFI_GUID gBrcmStbSdhciDeviceProtocolGuid;
|
||||
+
|
||||
+#endif // __BRCMSTB_SDHCI_DEVICE_H__
|
||||
--
|
||||
2.51.2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,611 @@
|
||||
From d9b5815d797260ca8c8af1f8cca19e85c8c32a09 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 29 Dec 2023 23:29:47 +0200
|
||||
Subject: [PATCH 09/16] Platform/RPi5: Add real-time clock support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Working get/set time and wake up alarm within UEFI.
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
.../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 110 ++++++-
|
||||
.../Include/IndustryStandard/RpiMbox.h | 2 +
|
||||
.../Include/Protocol/RpiFirmware.h | 28 ++
|
||||
.../RaspberryPi/Library/RpiRtcLib/RpiRtcLib.c | 305 ++++++++++++++++++
|
||||
.../Library/RpiRtcLib/RpiRtcLib.inf | 42 +++
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 2 +-
|
||||
6 files changed, 487 insertions(+), 2 deletions(-)
|
||||
create mode 100644 Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.c
|
||||
create mode 100644 Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.inf
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
index 9077f077..b432e828 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
@@ -1,5 +1,6 @@
|
||||
/** @file
|
||||
*
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
* Copyright (c) 2020, Pete Batard <pete@akeo.ie>
|
||||
* Copyright (c) 2019, ARM Limited. All rights reserved.
|
||||
* Copyright (c) 2017-2020, Andrei Warkentin <andrey.warkentin@gmail.com>
|
||||
@@ -1332,6 +1333,111 @@ RpiFirmwareNotifyGpioSetCfg (
|
||||
return Status;
|
||||
}
|
||||
|
||||
+
|
||||
+#pragma pack()
|
||||
+typedef struct {
|
||||
+ UINT32 Register;
|
||||
+ UINT32 Value;
|
||||
+} RPI_FW_RTC_TAG;
|
||||
+
|
||||
+typedef struct {
|
||||
+ RPI_FW_BUFFER_HEAD BufferHead;
|
||||
+ RPI_FW_TAG_HEAD TagHead;
|
||||
+ RPI_FW_RTC_TAG TagBody;
|
||||
+ UINT32 EndTag;
|
||||
+} RPI_FW_RTC_CMD;
|
||||
+#pragma pack()
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+RpiFirmwareGetRtc (
|
||||
+ IN RASPBERRY_PI_RTC_REGISTER Register,
|
||||
+ OUT UINT32 *Value
|
||||
+ )
|
||||
+{
|
||||
+ RPI_FW_RTC_CMD *Cmd;
|
||||
+ EFI_STATUS Status;
|
||||
+ UINT32 Result;
|
||||
+
|
||||
+ if (!AcquireSpinLockOrFail (&mMailboxLock)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
|
||||
+ return EFI_DEVICE_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ Cmd = mDmaBuffer;
|
||||
+ ZeroMem (Cmd, sizeof (*Cmd));
|
||||
+
|
||||
+ Cmd->BufferHead.BufferSize = sizeof (*Cmd);
|
||||
+ Cmd->BufferHead.Response = 0;
|
||||
+ Cmd->TagHead.TagId = RPI_MBOX_GET_RTC_REG;
|
||||
+ Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
|
||||
+ Cmd->TagHead.TagValueSize = 0;
|
||||
+ Cmd->TagBody.Register = Register;
|
||||
+ Cmd->TagBody.Value = 0;
|
||||
+ Cmd->EndTag = 0;
|
||||
+
|
||||
+ Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
|
||||
+
|
||||
+ if (EFI_ERROR (Status) ||
|
||||
+ Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
|
||||
+ DEBUG ((DEBUG_ERROR,
|
||||
+ "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
|
||||
+ __FUNCTION__, Status, Cmd->BufferHead.Response));
|
||||
+ Status = EFI_DEVICE_ERROR;
|
||||
+ } else {
|
||||
+ *Value = Cmd->TagBody.Value;
|
||||
+ }
|
||||
+
|
||||
+ ReleaseSpinLock (&mMailboxLock);
|
||||
+
|
||||
+ return Status;
|
||||
+}
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+RpiFirmwareSetRtc (
|
||||
+ IN RASPBERRY_PI_RTC_REGISTER Register,
|
||||
+ IN UINT32 Value
|
||||
+ )
|
||||
+{
|
||||
+ RPI_FW_RTC_CMD *Cmd;
|
||||
+ EFI_STATUS Status;
|
||||
+ UINT32 Result;
|
||||
+
|
||||
+ if (!AcquireSpinLockOrFail (&mMailboxLock)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
|
||||
+ return EFI_DEVICE_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ Cmd = mDmaBuffer;
|
||||
+ ZeroMem (Cmd, sizeof (*Cmd));
|
||||
+
|
||||
+ Cmd->BufferHead.BufferSize = sizeof (*Cmd);
|
||||
+ Cmd->BufferHead.Response = 0;
|
||||
+ Cmd->TagHead.TagId = RPI_MBOX_SET_RTC_REG;
|
||||
+ Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
|
||||
+ Cmd->TagHead.TagValueSize = 0;
|
||||
+ Cmd->TagBody.Register = Register;
|
||||
+ Cmd->TagBody.Value = Value;
|
||||
+ Cmd->EndTag = 0;
|
||||
+
|
||||
+ Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
|
||||
+
|
||||
+ if (EFI_ERROR (Status) ||
|
||||
+ Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
|
||||
+ DEBUG ((DEBUG_ERROR,
|
||||
+ "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
|
||||
+ __FUNCTION__, Status, Cmd->BufferHead.Response));
|
||||
+ Status = EFI_DEVICE_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ReleaseSpinLock (&mMailboxLock);
|
||||
+
|
||||
+ return Status;
|
||||
+}
|
||||
+
|
||||
STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
|
||||
RpiFirmwareSetPowerState,
|
||||
RpiFirmwareGetMacAddress,
|
||||
@@ -1352,7 +1458,9 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
|
||||
RpiFirmwareNotifyXhciReset,
|
||||
RpiFirmwareGetCurrentClockState,
|
||||
RpiFirmwareSetClockState,
|
||||
- RpiFirmwareNotifyGpioSetCfg
|
||||
+ RpiFirmwareNotifyGpioSetCfg,
|
||||
+ RpiFirmwareGetRtc,
|
||||
+ RpiFirmwareSetRtc,
|
||||
};
|
||||
|
||||
/**
|
||||
diff --git a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
|
||||
index 551c2b82..916b7442 100644
|
||||
--- a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
|
||||
+++ b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
|
||||
@@ -93,6 +93,7 @@
|
||||
#define RPI_MBOX_GET_POE_HAT_VAL 0x00030049
|
||||
#define RPI_MBOX_SET_POE_HAT_VAL 0x00030050
|
||||
#define RPI_MBOX_NOTIFY_XHCI_RESET 0x00030058
|
||||
+#define RPI_MBOX_GET_RTC_REG 0x00030087
|
||||
|
||||
#define RPI_MBOX_SET_CLOCK_STATE 0x00038001
|
||||
#define RPI_MBOX_SET_CLOCK_RATE 0x00038002
|
||||
@@ -104,6 +105,7 @@
|
||||
#define RPI_MBOX_SET_SDHOST_CLOCK 0x00038042
|
||||
#define RPI_MBOX_SET_GPIO_CONFIG 0x00038043
|
||||
#define RPI_MBOX_SET_PERIPH_REG 0x00038045
|
||||
+#define RPI_MBOX_SET_RTC_REG 0x00038087
|
||||
|
||||
#define RPI_MBOX_ALLOC_FB 0x00040001
|
||||
#define RPI_MBOX_FB_BLANK 0x00040002
|
||||
diff --git a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
|
||||
index 86bf1687..92ab7f84 100644
|
||||
--- a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
|
||||
+++ b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
|
||||
@@ -1,5 +1,6 @@
|
||||
/** @file
|
||||
*
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
* Copyright (c) 2019, ARM Limited. All rights reserved.
|
||||
* Copyright (c) 2017 - 2020, Andrei Warkentin <andrey.warkentin@gmail.com>
|
||||
* Copyright (c) 2016, Linaro Limited. All rights reserved.
|
||||
@@ -14,6 +15,17 @@
|
||||
#define RASPBERRY_PI_FIRMWARE_PROTOL_GUID \
|
||||
{ 0x0ACA9535, 0x7AD0, 0x4286, { 0xB0, 0x2E, 0x87, 0xFA, 0x7E, 0x2A, 0x57, 0x11 } }
|
||||
|
||||
+typedef enum {
|
||||
+ RpiRtcTime = 0,
|
||||
+ RpiRtcAlarm,
|
||||
+ RpiRtcAlarmPending,
|
||||
+ RpiRtcAlarmEnable,
|
||||
+ RpiRtcBatteryChargeVoltage,
|
||||
+ RpiRtcBatteryChargeVoltageMin,
|
||||
+ RpiRtcBatteryChargeVoltageMax,
|
||||
+ RpiRtcBatteryVoltage,
|
||||
+} RASPBERRY_PI_RTC_REGISTER;
|
||||
+
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *SET_POWER_STATE) (
|
||||
@@ -141,6 +153,20 @@ EFI_STATUS
|
||||
UINTN State
|
||||
);
|
||||
|
||||
+typedef
|
||||
+EFI_STATUS
|
||||
+(EFIAPI *GET_RTC) (
|
||||
+ IN RASPBERRY_PI_RTC_REGISTER Register,
|
||||
+ OUT UINT32 *Value
|
||||
+ );
|
||||
+
|
||||
+typedef
|
||||
+EFI_STATUS
|
||||
+(EFIAPI *SET_RTC) (
|
||||
+ IN RASPBERRY_PI_RTC_REGISTER Register,
|
||||
+ IN UINT32 Value
|
||||
+ );
|
||||
+
|
||||
typedef struct {
|
||||
SET_POWER_STATE SetPowerState;
|
||||
GET_MAC_ADDRESS GetMacAddress;
|
||||
@@ -162,6 +188,8 @@ typedef struct {
|
||||
GET_CLOCK_STATE GetClockState;
|
||||
SET_CLOCK_STATE SetClockState;
|
||||
GPIO_SET_CFG SetGpioConfig;
|
||||
+ GET_RTC GetRtc;
|
||||
+ SET_RTC SetRtc;
|
||||
} RASPBERRY_PI_FIRMWARE_PROTOCOL;
|
||||
|
||||
extern EFI_GUID gRaspberryPiFirmwareProtocolGuid;
|
||||
diff --git a/Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.c b/Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.c
|
||||
new file mode 100644
|
||||
index 00000000..298b3678
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.c
|
||||
@@ -0,0 +1,305 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <PiDxe.h>
|
||||
+
|
||||
+#include <Library/DebugLib.h>
|
||||
+#include <Library/RealTimeClockLib.h>
|
||||
+#include <Library/TimeBaseLib.h>
|
||||
+#include <Library/UefiBootServicesTableLib.h>
|
||||
+#include <Library/UefiRuntimeLib.h>
|
||||
+
|
||||
+#include <Protocol/RpiFirmware.h>
|
||||
+
|
||||
+STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
|
||||
+
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+OffsetTimeZoneEpoch (
|
||||
+ IN EFI_TIME *Time,
|
||||
+ IN OUT UINT32 *EpochSeconds,
|
||||
+ IN BOOLEAN Add
|
||||
+ )
|
||||
+{
|
||||
+ //
|
||||
+ // Adjust for the correct time zone
|
||||
+ // The timezone setting also reflects the DST setting of the clock
|
||||
+ //
|
||||
+ if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
|
||||
+ *EpochSeconds += (Add ? 1 : -1) * Time->TimeZone * SEC_PER_MIN;
|
||||
+ } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
|
||||
+ // Convert to adjusted time, i.e. spring forwards one hour
|
||||
+ *EpochSeconds += (Add ? 1 : -1) * SEC_PER_HOUR;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ Returns the current time and date information, and the time-keeping capabilities
|
||||
+ of the hardware platform.
|
||||
+
|
||||
+ @param Time A pointer to storage to receive a snapshot of the current time.
|
||||
+ @param Capabilities An optional pointer to a buffer to receive the real time clock
|
||||
+ device's capabilities.
|
||||
+
|
||||
+ @retval EFI_SUCCESS The operation completed successfully.
|
||||
+ @retval EFI_INVALID_PARAMETER Time is NULL.
|
||||
+ @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
|
||||
+ @retval EFI_SECURITY_VIOLATION The time could not be retrieved due to an authentication failure.
|
||||
+
|
||||
+**/
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+LibGetTime (
|
||||
+ OUT EFI_TIME *Time,
|
||||
+ OUT EFI_TIME_CAPABILITIES *Capabilities
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ UINT32 EpochSeconds;
|
||||
+
|
||||
+ if (Time == NULL) {
|
||||
+ return EFI_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
+ Status = mFwProtocol->GetRtc (RpiRtcTime, &EpochSeconds);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ OffsetTimeZoneEpoch (Time, &EpochSeconds, TRUE);
|
||||
+
|
||||
+ EpochToEfiTime (EpochSeconds, Time);
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ Sets the current local time and date information.
|
||||
+
|
||||
+ @param Time A pointer to the current time.
|
||||
+
|
||||
+ @retval EFI_SUCCESS The operation completed successfully.
|
||||
+ @retval EFI_INVALID_PARAMETER A time field is out of range.
|
||||
+ @retval EFI_DEVICE_ERROR The time could not be set due to hardware error.
|
||||
+
|
||||
+**/
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+LibSetTime (
|
||||
+ IN EFI_TIME *Time
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ UINT32 EpochSeconds;
|
||||
+
|
||||
+ if (Time == NULL || !IsTimeValid (Time)) {
|
||||
+ return EFI_UNSUPPORTED;
|
||||
+ }
|
||||
+
|
||||
+ EpochSeconds = (UINT32)EfiTimeToEpoch (Time);
|
||||
+
|
||||
+ OffsetTimeZoneEpoch (Time, &EpochSeconds, FALSE);
|
||||
+
|
||||
+ Status = mFwProtocol->SetRtc (RpiRtcTime, EpochSeconds);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ Returns the current wakeup alarm clock setting.
|
||||
+
|
||||
+ @param Enabled Indicates if the alarm is currently enabled or disabled.
|
||||
+ @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
|
||||
+ @param Time The current alarm setting.
|
||||
+
|
||||
+ @retval EFI_SUCCESS The alarm settings were returned.
|
||||
+ @retval EFI_INVALID_PARAMETER Any parameter is NULL.
|
||||
+ @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
|
||||
+
|
||||
+**/
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+LibGetWakeupTime (
|
||||
+ OUT BOOLEAN *Enabled,
|
||||
+ OUT BOOLEAN *Pending,
|
||||
+ OUT EFI_TIME *Time
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ UINT32 EpochSeconds;
|
||||
+ UINT32 EnableVal;
|
||||
+ UINT32 PendingVal;
|
||||
+
|
||||
+ if (Time == NULL || Enabled == NULL || Pending == NULL) {
|
||||
+ return EFI_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
+ Status = mFwProtocol->GetRtc (RpiRtcAlarmEnable, &EnableVal);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ Status = mFwProtocol->GetRtc (RpiRtcAlarmPending, &PendingVal);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ *Enabled = EnableVal;
|
||||
+ *Pending = PendingVal;
|
||||
+
|
||||
+ if (*Pending) {
|
||||
+ // Acknowledge alarm
|
||||
+ Status = mFwProtocol->SetRtc (RpiRtcAlarmPending, TRUE);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ Status = mFwProtocol->GetRtc (RpiRtcAlarm, &EpochSeconds);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ OffsetTimeZoneEpoch (Time, &EpochSeconds, TRUE);
|
||||
+
|
||||
+ EpochToEfiTime (EpochSeconds, Time);
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ Sets the system wakeup alarm clock time.
|
||||
+
|
||||
+ @param Enabled Enable or disable the wakeup alarm.
|
||||
+ @param Time If Enable is TRUE, the time to set the wakeup alarm for.
|
||||
+
|
||||
+ @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
|
||||
+ Enable is FALSE, then the wakeup alarm was disabled.
|
||||
+ @retval EFI_INVALID_PARAMETER A time field is out of range.
|
||||
+ @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
|
||||
+ @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
|
||||
+
|
||||
+**/
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+LibSetWakeupTime (
|
||||
+ IN BOOLEAN Enabled,
|
||||
+ OUT EFI_TIME *Time
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ UINT32 EpochSeconds;
|
||||
+
|
||||
+ if (Enabled) {
|
||||
+ if (Time == NULL || !IsTimeValid (Time)) {
|
||||
+ return EFI_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
+ EpochSeconds = (UINT32)EfiTimeToEpoch (Time);
|
||||
+
|
||||
+ OffsetTimeZoneEpoch (Time, &EpochSeconds, FALSE);
|
||||
+
|
||||
+ Status = mFwProtocol->SetRtc (RpiRtcAlarm, EpochSeconds);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ Status = mFwProtocol->SetRtc (RpiRtcAlarmEnable, Enabled);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ Fixup internal data so that EFI can be call in virtual mode.
|
||||
+ Call the passed in Child Notify event and convert any pointers in
|
||||
+ lib to virtual mode.
|
||||
+
|
||||
+ @param[in] Event The Event that is being processed
|
||||
+ @param[in] Context Event Context
|
||||
+
|
||||
+**/
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+VirtualAddressChangeNotify (
|
||||
+ IN EFI_EVENT Event,
|
||||
+ IN VOID *Context
|
||||
+ )
|
||||
+{
|
||||
+ EfiConvertPointer (0x0, (VOID **)&mFwProtocol);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ This is the declaration of an EFI image entry point. This can be the entry point to an application
|
||||
+ written to this specification, an EFI boot service driver, or an EFI runtime driver.
|
||||
+
|
||||
+ @param ImageHandle Handle that identifies the loaded image.
|
||||
+ @param SystemTable System Table for this image.
|
||||
+
|
||||
+ @retval EFI_SUCCESS The operation completed successfully.
|
||||
+
|
||||
+**/
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+LibRtcInitialize (
|
||||
+ IN EFI_HANDLE ImageHandle,
|
||||
+ IN EFI_SYSTEM_TABLE *SystemTable
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ EFI_TIME Time;
|
||||
+ EFI_EVENT VirtualAddressChangeEvent;
|
||||
+
|
||||
+ Status = gBS->LocateProtocol (
|
||||
+ &gRaspberryPiFirmwareProtocolGuid,
|
||||
+ NULL,
|
||||
+ (VOID **)&mFwProtocol);
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ Status = gBS->CreateEventEx (
|
||||
+ EVT_NOTIFY_SIGNAL,
|
||||
+ TPL_NOTIFY,
|
||||
+ VirtualAddressChangeNotify,
|
||||
+ NULL,
|
||||
+ &gEfiEventVirtualAddressChangeGuid,
|
||||
+ &VirtualAddressChangeEvent);
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ //
|
||||
+ // Initial RTC time starts off at Epoch = 0, which is out
|
||||
+ // of UEFI's bounds. Update it to the firmware build time.
|
||||
+ //
|
||||
+ Status = LibGetTime (&Time, NULL);
|
||||
+ if (EFI_ERROR(Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ if (!IsTimeValid (&Time)) {
|
||||
+ EpochToEfiTime (BUILD_EPOCH, &Time);
|
||||
+ Status = LibSetTime (&Time);
|
||||
+ if (EFI_ERROR(Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
diff --git a/Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.inf b/Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.inf
|
||||
new file mode 100644
|
||||
index 00000000..f271f39c
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.inf
|
||||
@@ -0,0 +1,42 @@
|
||||
+#/** @file
|
||||
+#
|
||||
+# Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+#
|
||||
+#**/
|
||||
+
|
||||
+[Defines]
|
||||
+ INF_VERSION = 0x0001001A
|
||||
+ BASE_NAME = RpiRtcLib
|
||||
+ FILE_GUID = 2c823916-13b7-48f3-bb6d-a8cf438b91fd
|
||||
+ MODULE_TYPE = BASE
|
||||
+ VERSION_STRING = 1.0
|
||||
+ LIBRARY_CLASS = RealTimeClockLib
|
||||
+
|
||||
+[Sources.common]
|
||||
+ RpiRtcLib.c
|
||||
+
|
||||
+[Packages]
|
||||
+ EmbeddedPkg/EmbeddedPkg.dec
|
||||
+ MdePkg/MdePkg.dec
|
||||
+ Platform/RaspberryPi/RaspberryPi.dec
|
||||
+
|
||||
+[LibraryClasses]
|
||||
+ DebugLib
|
||||
+ TimeBaseLib
|
||||
+ UefiBootServicesTableLib
|
||||
+ UefiRuntimeLib
|
||||
+
|
||||
+[Guids]
|
||||
+ gEfiEventVirtualAddressChangeGuid
|
||||
+
|
||||
+[Protocols]
|
||||
+ gRaspberryPiFirmwareProtocolGuid ## CONSUMES
|
||||
+
|
||||
+[Depex]
|
||||
+ gRaspberryPiFirmwareProtocolGuid
|
||||
+
|
||||
+# Current usage of this library expects GCC in a UNIX-like shell environment with the date command
|
||||
+[BuildOptions]
|
||||
+ GCC:*_*_*_CC_FLAGS = -DBUILD_EPOCH=`date +%s`
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index f8e08de2..f2a1992e 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -547,7 +547,7 @@
|
||||
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
|
||||
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
|
||||
<LibraryClasses>
|
||||
- RealTimeClockLib|EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
|
||||
+ RealTimeClockLib|Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.inf
|
||||
}
|
||||
EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
|
||||
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
From eeb78653af963f45e371e2ac5ce09e1445158642 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 29 Dec 2023 23:49:33 +0200
|
||||
Subject: [PATCH 10/16] Platform/RaspberryPi: Enable runtime use of
|
||||
RpiFirmwareDxe
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
.../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 91 ++++++++++++++++---
|
||||
.../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf | 8 +-
|
||||
2 files changed, 87 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
index b432e828..64db6506 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
|
||||
@@ -16,25 +16,29 @@
|
||||
#include <Library/DmaLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
+#include <Library/CacheMaintenanceLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
+#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/SynchronizationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
+#include <Library/UefiRuntimeLib.h>
|
||||
|
||||
#include <IndustryStandard/Bcm2836Mbox.h>
|
||||
#include <IndustryStandard/RpiMbox.h>
|
||||
|
||||
#include <Protocol/RpiFirmware.h>
|
||||
|
||||
-#define MBOX_BASE_ADDRESS PcdGet64 (PcdFwMailboxBaseAddress)
|
||||
-
|
||||
//
|
||||
// The number of statically allocated buffer pages
|
||||
//
|
||||
#define NUM_PAGES 1
|
||||
|
||||
+STATIC UINTN mMboxBaseAddress;
|
||||
+
|
||||
STATIC VOID *mDmaBuffer;
|
||||
+STATIC UINTN mDmaBufferSize;
|
||||
STATIC VOID *mDmaBufferMapping;
|
||||
STATIC UINTN mDmaBufferBusAddress;
|
||||
|
||||
@@ -54,12 +58,12 @@ DrainMailbox (
|
||||
//
|
||||
Tries = 0;
|
||||
do {
|
||||
- Val = MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
|
||||
+ Val = MmioRead32 (mMboxBaseAddress + BCM2836_MBOX_STATUS_OFFSET);
|
||||
if (Val & (1U << BCM2836_MBOX_STATUS_EMPTY)) {
|
||||
return TRUE;
|
||||
}
|
||||
ArmDataSynchronizationBarrier ();
|
||||
- MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
|
||||
+ MmioRead32 (mMboxBaseAddress + BCM2836_MBOX_READ_OFFSET);
|
||||
} while (++Tries < RPI_MBOX_MAX_TRIES);
|
||||
|
||||
return FALSE;
|
||||
@@ -79,7 +83,7 @@ MailboxWaitForStatusCleared (
|
||||
//
|
||||
Tries = 0;
|
||||
do {
|
||||
- Val = MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
|
||||
+ Val = MmioRead32 (mMboxBaseAddress + BCM2836_MBOX_STATUS_OFFSET);
|
||||
if ((Val & StatusMask) == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -119,12 +123,20 @@ MailboxTransaction (
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
+ //
|
||||
+ // The DMA buffer is initially mapped as WC/Normal-NC, but it
|
||||
+ // somehow ends up being cached at runtime.
|
||||
+ //
|
||||
+ if (EfiAtRuntime ()) {
|
||||
+ WriteBackDataCacheRange (mDmaBuffer, mDmaBufferSize);
|
||||
+ }
|
||||
+
|
||||
ArmDataSynchronizationBarrier ();
|
||||
|
||||
//
|
||||
// Start the mailbox transaction
|
||||
//
|
||||
- MmioWrite32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_WRITE_OFFSET,
|
||||
+ MmioWrite32 (mMboxBaseAddress + BCM2836_MBOX_WRITE_OFFSET,
|
||||
(UINT32)((UINTN)mDmaBufferBusAddress | Channel));
|
||||
|
||||
ArmDataSynchronizationBarrier ();
|
||||
@@ -138,11 +150,15 @@ MailboxTransaction (
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
+ if (EfiAtRuntime ()) {
|
||||
+ InvalidateDataCacheRange (mDmaBuffer, mDmaBufferSize);
|
||||
+ }
|
||||
+
|
||||
//
|
||||
// Read back the result
|
||||
//
|
||||
ArmDataSynchronizationBarrier ();
|
||||
- *Result = MmioRead32 (MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
|
||||
+ *Result = MmioRead32 (mMboxBaseAddress + BCM2836_MBOX_READ_OFFSET);
|
||||
ArmDataSynchronizationBarrier ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -1463,6 +1479,20 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
|
||||
RpiFirmwareSetRtc,
|
||||
};
|
||||
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+RpiFirmwareVirtualAddressChangeNotify (
|
||||
+ IN EFI_EVENT Event,
|
||||
+ IN VOID *Context
|
||||
+ )
|
||||
+{
|
||||
+ EfiConvertPointer (0x0, (VOID **)&mMboxBaseAddress);
|
||||
+ EfiConvertPointer (0x0, (VOID **)&mDmaBuffer);
|
||||
+ EfiConvertPointer (0x0, (VOID **)&mRpiFirmwareProtocol.GetRtc);
|
||||
+ EfiConvertPointer (0x0, (VOID **)&mRpiFirmwareProtocol.SetRtc);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
Initialize the state information for the CPU Architectural Protocol
|
||||
|
||||
@@ -1481,7 +1511,10 @@ RpiFirmwareDxeInitialize (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
- UINTN BufferSize;
|
||||
+ UINTN AlignedMboxAddress;
|
||||
+ EFI_EVENT VirtualAddressChangeEvent = NULL;
|
||||
+
|
||||
+ mMboxBaseAddress = PcdGet64 (PcdFwMailboxBaseAddress);
|
||||
|
||||
//
|
||||
// We only need one of these
|
||||
@@ -1490,14 +1523,14 @@ RpiFirmwareDxeInitialize (
|
||||
|
||||
InitializeSpinLock (&mMailboxLock);
|
||||
|
||||
- Status = DmaAllocateBuffer (EfiBootServicesData, NUM_PAGES, &mDmaBuffer);
|
||||
+ Status = DmaAllocateBuffer (EfiRuntimeServicesData, NUM_PAGES, &mDmaBuffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to allocate DMA buffer (Status == %r)\n", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
- BufferSize = EFI_PAGES_TO_SIZE (NUM_PAGES);
|
||||
- Status = DmaMap (MapOperationBusMasterCommonBuffer, mDmaBuffer, &BufferSize,
|
||||
+ mDmaBufferSize = EFI_PAGES_TO_SIZE (NUM_PAGES);
|
||||
+ Status = DmaMap (MapOperationBusMasterCommonBuffer, mDmaBuffer, &mDmaBufferSize,
|
||||
&mDmaBufferBusAddress, &mDmaBufferMapping);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to map DMA buffer (Status == %r)\n", __FUNCTION__));
|
||||
@@ -1520,6 +1553,42 @@ RpiFirmwareDxeInitialize (
|
||||
goto UnmapBuffer;
|
||||
}
|
||||
|
||||
+ AlignedMboxAddress = mMboxBaseAddress & ~(EFI_PAGE_SIZE - 1);
|
||||
+
|
||||
+ Status = gDS->AddMemorySpace (
|
||||
+ EfiGcdMemoryTypeMemoryMappedIo,
|
||||
+ AlignedMboxAddress,
|
||||
+ EFI_PAGE_SIZE,
|
||||
+ EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: AddMemorySpace failed. Status=%r\n",
|
||||
+ __FUNCTION__, Status));
|
||||
+ goto UnmapBuffer;
|
||||
+ }
|
||||
+
|
||||
+ Status = gDS->SetMemorySpaceAttributes (
|
||||
+ AlignedMboxAddress,
|
||||
+ EFI_PAGE_SIZE,
|
||||
+ EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: SetMemorySpaceAttributes failed. Status=%r\n",
|
||||
+ __FUNCTION__, Status));
|
||||
+ goto UnmapBuffer;
|
||||
+ }
|
||||
+
|
||||
+ Status = gBS->CreateEventEx (
|
||||
+ EVT_NOTIFY_SIGNAL,
|
||||
+ TPL_NOTIFY,
|
||||
+ RpiFirmwareVirtualAddressChangeNotify,
|
||||
+ NULL,
|
||||
+ &gEfiEventVirtualAddressChangeGuid,
|
||||
+ &VirtualAddressChangeEvent);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "%a: failed to register for virtual address change. Status=%r\n",
|
||||
+ __func__, Status));
|
||||
+ goto UnmapBuffer;
|
||||
+ }
|
||||
+
|
||||
return EFI_SUCCESS;
|
||||
|
||||
UnmapBuffer:
|
||||
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
index 08acc4b3..1ab8d0b7 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
@@ -11,7 +11,7 @@
|
||||
INF_VERSION = 0x0001001A
|
||||
BASE_NAME = RpiFirmwareDxe
|
||||
FILE_GUID = 6d4628df-49a0-4b67-a325-d5af35c65745
|
||||
- MODULE_TYPE = DXE_DRIVER
|
||||
+ MODULE_TYPE = DXE_RUNTIME_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = RpiFirmwareDxeInitialize
|
||||
|
||||
@@ -29,13 +29,19 @@
|
||||
ArmLib
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
+ CacheMaintenanceLib
|
||||
DebugLib
|
||||
DmaLib
|
||||
+ DxeServicesTableLib
|
||||
IoLib
|
||||
SynchronizationLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
UefiLib
|
||||
+ UefiRuntimeLib
|
||||
+
|
||||
+[Guids]
|
||||
+ gEfiEventVirtualAddressChangeGuid
|
||||
|
||||
[Protocols]
|
||||
gRaspberryPiFirmwareProtocolGuid ## PRODUCES
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,511 @@
|
||||
From 207315a9fadbfbe7de68cec9e47a0a9be8fea882 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Sun, 31 Dec 2023 21:04:23 +0200
|
||||
Subject: [PATCH 11/16] =?UTF-8?q?=EF=BB=BFPlatform/RaspberryPi:=20Add=20op?=
|
||||
=?UTF-8?q?tion=20to=20disable=20EFI=20Memory=20Attribute=20Protocol?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Introduce a driver that allows disabling this protocol via a HII option.
|
||||
Default is enabled, which can also be overridden at build time by
|
||||
changing `gRaspberryPiTokenSpaceGuid.PcdMemoryAttributeEnabledDefault`.
|
||||
|
||||
This should probably be done in core EDK2 though, it's clear that it
|
||||
will take distros more time to catch up and suddenly breaking
|
||||
compatibility like this isn't great for end users.
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
.../MemoryAttributeManagerDxe.c | 180 ++++++++++++++++++
|
||||
.../MemoryAttributeManagerDxe.h | 22 +++
|
||||
.../MemoryAttributeManagerDxe.inf | 47 +++++
|
||||
.../MemoryAttributeManagerDxeHii.uni | 17 ++
|
||||
.../MemoryAttributeManagerDxeHii.vfr | 35 ++++
|
||||
.../Guid/MemoryAttributeManagerFormSet.h | 17 ++
|
||||
Platform/RaspberryPi/RPi3/RPi3.dsc | 5 +
|
||||
Platform/RaspberryPi/RPi3/RPi3.fdf | 5 +
|
||||
Platform/RaspberryPi/RPi4/RPi4.dsc | 5 +
|
||||
Platform/RaspberryPi/RPi4/RPi4.fdf | 5 +
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 5 +
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 5 +
|
||||
Platform/RaspberryPi/RaspberryPi.dec | 2 +
|
||||
13 files changed, 350 insertions(+)
|
||||
create mode 100644 Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.c
|
||||
create mode 100644 Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.h
|
||||
create mode 100644 Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
create mode 100644 Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.uni
|
||||
create mode 100644 Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.vfr
|
||||
create mode 100644 Platform/RaspberryPi/Include/Guid/MemoryAttributeManagerFormSet.h
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.c b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.c
|
||||
new file mode 100644
|
||||
index 00000000..0c6f6e28
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.c
|
||||
@@ -0,0 +1,180 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <Uefi.h>
|
||||
+#include <Library/DebugLib.h>
|
||||
+#include <Library/DevicePathLib.h>
|
||||
+#include <Library/HiiLib.h>
|
||||
+#include <Library/UefiBootServicesTableLib.h>
|
||||
+#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
+
|
||||
+#include "MemoryAttributeManagerDxe.h"
|
||||
+
|
||||
+extern UINT8 MemoryAttributeManagerDxeHiiBin[];
|
||||
+extern UINT8 MemoryAttributeManagerDxeStrings[];
|
||||
+
|
||||
+typedef struct {
|
||||
+ VENDOR_DEVICE_PATH VendorDevicePath;
|
||||
+ EFI_DEVICE_PATH_PROTOCOL End;
|
||||
+} HII_VENDOR_DEVICE_PATH;
|
||||
+
|
||||
+STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = {
|
||||
+ {
|
||||
+ {
|
||||
+ HARDWARE_DEVICE_PATH,
|
||||
+ HW_VENDOR_DP,
|
||||
+ {
|
||||
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
|
||||
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
|
||||
+ }
|
||||
+ },
|
||||
+ MEMORY_ATTRIBUTE_MANAGER_FORMSET_GUID
|
||||
+ },
|
||||
+ {
|
||||
+ END_DEVICE_PATH_TYPE,
|
||||
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
||||
+ {
|
||||
+ (UINT8)(END_DEVICE_PATH_LENGTH),
|
||||
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
|
||||
+ }
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+STATIC
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+InstallHiiPages (
|
||||
+ VOID
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ EFI_HII_HANDLE HiiHandle;
|
||||
+ EFI_HANDLE DriverHandle;
|
||||
+
|
||||
+ DriverHandle = NULL;
|
||||
+ Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
+ &DriverHandle,
|
||||
+ &gEfiDevicePathProtocolGuid,
|
||||
+ &mVendorDevicePath,
|
||||
+ NULL
|
||||
+ );
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return Status;
|
||||
+ }
|
||||
+
|
||||
+ HiiHandle = HiiAddPackages (
|
||||
+ &gMemoryAttributeManagerFormSetGuid,
|
||||
+ DriverHandle,
|
||||
+ MemoryAttributeManagerDxeStrings,
|
||||
+ MemoryAttributeManagerDxeHiiBin,
|
||||
+ NULL
|
||||
+ );
|
||||
+
|
||||
+ if (HiiHandle == NULL) {
|
||||
+ gBS->UninstallMultipleProtocolInterfaces (
|
||||
+ DriverHandle,
|
||||
+ &gEfiDevicePathProtocolGuid,
|
||||
+ &mVendorDevicePath,
|
||||
+ NULL
|
||||
+ );
|
||||
+ return EFI_OUT_OF_RESOURCES;
|
||||
+ }
|
||||
+
|
||||
+ return EFI_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ This function uninstalls the recently added EFI_MEMORY_ATTRIBUTE_PROTOCOL
|
||||
+ to workaround older versions of OS loaders/shims using it incorrectly and
|
||||
+ throwing a Synchronous Exception.
|
||||
+ See:
|
||||
+ - https://github.com/microsoft/mu_silicon_arm_tiano/issues/124
|
||||
+ - https://edk2.groups.io/g/devel/topic/99631663
|
||||
+**/
|
||||
+STATIC
|
||||
+VOID
|
||||
+UninstallEfiMemoryAttributeProtocol (
|
||||
+ VOID
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ EFI_HANDLE Handle;
|
||||
+ UINTN Size;
|
||||
+ VOID *MemoryAttributeProtocol;
|
||||
+
|
||||
+ Size = sizeof (Handle);
|
||||
+ Status = gBS->LocateHandle (
|
||||
+ ByProtocol,
|
||||
+ &gEfiMemoryAttributeProtocolGuid,
|
||||
+ NULL,
|
||||
+ &Size,
|
||||
+ &Handle
|
||||
+ );
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ ASSERT (Status == EFI_NOT_FOUND);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Status = gBS->HandleProtocol (
|
||||
+ Handle,
|
||||
+ &gEfiMemoryAttributeProtocolGuid,
|
||||
+ &MemoryAttributeProtocol
|
||||
+ );
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Status = gBS->UninstallProtocolInterface (
|
||||
+ Handle,
|
||||
+ &gEfiMemoryAttributeProtocolGuid,
|
||||
+ MemoryAttributeProtocol
|
||||
+ );
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+
|
||||
+ DEBUG ((DEBUG_INFO, "%a: Done!\n", __func__));
|
||||
+}
|
||||
+
|
||||
+EFI_STATUS
|
||||
+EFIAPI
|
||||
+MemoryAttributeManagerInitialize (
|
||||
+ IN EFI_HANDLE ImageHandle,
|
||||
+ IN EFI_SYSTEM_TABLE *SystemTable
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ UINTN Size;
|
||||
+ MEMORY_ATTRIBUTE_MANAGER_VARSTORE_DATA Config;
|
||||
+
|
||||
+ Config.Enabled = PROTOCOL_ENABLED_DEFAULT;
|
||||
+
|
||||
+ Size = sizeof (MEMORY_ATTRIBUTE_MANAGER_VARSTORE_DATA);
|
||||
+ Status = gRT->GetVariable (
|
||||
+ MEMORY_ATTRIBUTE_MANAGER_DATA_VAR_NAME,
|
||||
+ &gMemoryAttributeManagerFormSetGuid,
|
||||
+ NULL,
|
||||
+ &Size,
|
||||
+ &Config
|
||||
+ );
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ Status = gRT->SetVariable (
|
||||
+ MEMORY_ATTRIBUTE_MANAGER_DATA_VAR_NAME,
|
||||
+ &gMemoryAttributeManagerFormSetGuid,
|
||||
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
|
||||
+ Size,
|
||||
+ &Config
|
||||
+ );
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ }
|
||||
+
|
||||
+ if (!Config.Enabled) {
|
||||
+ UninstallEfiMemoryAttributeProtocol ();
|
||||
+ }
|
||||
+
|
||||
+ return InstallHiiPages ();
|
||||
+}
|
||||
diff --git a/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.h b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.h
|
||||
new file mode 100644
|
||||
index 00000000..9db0568d
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.h
|
||||
@@ -0,0 +1,22 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#ifndef __MEMORY_ATTRIBUTE_MANAGER_DXE_H__
|
||||
+#define __MEMORY_ATTRIBUTE_MANAGER_DXE_H__
|
||||
+
|
||||
+#include <Guid/MemoryAttributeManagerFormSet.h>
|
||||
+
|
||||
+#define PROTOCOL_ENABLED_DEFAULT FixedPcdGetBool(PcdMemoryAttributeEnabledDefault)
|
||||
+
|
||||
+#define MEMORY_ATTRIBUTE_MANAGER_DATA_VAR_NAME L"MemoryAttributeManagerData"
|
||||
+
|
||||
+typedef struct {
|
||||
+ BOOLEAN Enabled;
|
||||
+} MEMORY_ATTRIBUTE_MANAGER_VARSTORE_DATA;
|
||||
+
|
||||
+#endif // __MEMORY_ATTRIBUTE_MANAGER_DXE_H__
|
||||
diff --git a/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
new file mode 100644
|
||||
index 00000000..ae36810d
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
@@ -0,0 +1,47 @@
|
||||
+#/** @file
|
||||
+#
|
||||
+# Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+#
|
||||
+#**/
|
||||
+
|
||||
+[Defines]
|
||||
+ INF_VERSION = 0x0001001B
|
||||
+ BASE_NAME = MemoryAttributeManagerDxe
|
||||
+ FILE_GUID = 5319346b-66ad-433a-9a91-f7fc286bc9a1
|
||||
+ MODULE_TYPE = DXE_DRIVER
|
||||
+ VERSION_STRING = 1.0
|
||||
+ ENTRY_POINT = MemoryAttributeManagerInitialize
|
||||
+
|
||||
+[Sources]
|
||||
+ MemoryAttributeManagerDxe.c
|
||||
+ MemoryAttributeManagerDxeHii.uni
|
||||
+ MemoryAttributeManagerDxeHii.vfr
|
||||
+
|
||||
+[Packages]
|
||||
+ MdePkg/MdePkg.dec
|
||||
+ MdeModulePkg/MdeModulePkg.dec
|
||||
+ Platform/RaspberryPi/RaspberryPi.dec
|
||||
+
|
||||
+[LibraryClasses]
|
||||
+ DebugLib
|
||||
+ DevicePathLib
|
||||
+ HiiLib
|
||||
+ UefiBootServicesTableLib
|
||||
+ UefiRuntimeServicesTableLib
|
||||
+ UefiDriverEntryPoint
|
||||
+
|
||||
+[Guids]
|
||||
+ gMemoryAttributeManagerFormSetGuid
|
||||
+
|
||||
+[Protocols]
|
||||
+ gEfiMemoryAttributeProtocolGuid
|
||||
+
|
||||
+[Pcd]
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdMemoryAttributeEnabledDefault
|
||||
+
|
||||
+[Depex]
|
||||
+ gEfiVariableArchProtocolGuid
|
||||
+ AND gEfiVariableWriteArchProtocolGuid
|
||||
+ AND gEfiMemoryAttributeProtocolGuid
|
||||
diff --git a/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.uni b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.uni
|
||||
new file mode 100644
|
||||
index 00000000..f78ed725
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.uni
|
||||
@@ -0,0 +1,17 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#langdef en-US "English"
|
||||
+
|
||||
+#string STR_NULL_STRING #language en-US ""
|
||||
+
|
||||
+#string STR_FORM_SET_TITLE #language en-US "EFI Memory Attribute Protocol"
|
||||
+#string STR_FORM_SET_TITLE_HELP #language en-US "Configure the state of the EFI Memory Attribute Protocol."
|
||||
+
|
||||
+#string STR_ENABLE_PROTOCOL_PROMPT #language en-US "Enable Protocol"
|
||||
+#string STR_ENABLE_PROTOCOL_HELP #language en-US "Some OS loader versions do not properly support the memory attribute protocol and may cause a Synchronous Exception. This option can be disabled to work around the issue."
|
||||
diff --git a/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.vfr b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.vfr
|
||||
new file mode 100644
|
||||
index 00000000..cdf2be8b
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxeHii.vfr
|
||||
@@ -0,0 +1,35 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#include <Uefi/UefiMultiPhase.h>
|
||||
+#include <Guid/HiiPlatformSetupFormset.h>
|
||||
+
|
||||
+#include "MemoryAttributeManagerDxe.h"
|
||||
+
|
||||
+formset
|
||||
+ guid = MEMORY_ATTRIBUTE_MANAGER_FORMSET_GUID,
|
||||
+ title = STRING_TOKEN(STR_FORM_SET_TITLE),
|
||||
+ help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
|
||||
+ classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
|
||||
+
|
||||
+ efivarstore MEMORY_ATTRIBUTE_MANAGER_VARSTORE_DATA,
|
||||
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
+ name = MemoryAttributeManagerData,
|
||||
+ guid = MEMORY_ATTRIBUTE_MANAGER_FORMSET_GUID;
|
||||
+
|
||||
+ form formid = 1,
|
||||
+ title = STRING_TOKEN(STR_FORM_SET_TITLE);
|
||||
+
|
||||
+ checkbox varid = MemoryAttributeManagerData.Enabled,
|
||||
+ prompt = STRING_TOKEN(STR_ENABLE_PROTOCOL_PROMPT),
|
||||
+ help = STRING_TOKEN(STR_ENABLE_PROTOCOL_HELP),
|
||||
+ flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
|
||||
+ default = PROTOCOL_ENABLED_DEFAULT,
|
||||
+ endcheckbox;
|
||||
+ endform;
|
||||
+endformset;
|
||||
diff --git a/Platform/RaspberryPi/Include/Guid/MemoryAttributeManagerFormSet.h b/Platform/RaspberryPi/Include/Guid/MemoryAttributeManagerFormSet.h
|
||||
new file mode 100644
|
||||
index 00000000..b480f313
|
||||
--- /dev/null
|
||||
+++ b/Platform/RaspberryPi/Include/Guid/MemoryAttributeManagerFormSet.h
|
||||
@@ -0,0 +1,17 @@
|
||||
+/** @file
|
||||
+ *
|
||||
+ * Copyright (c) 2023, Mario Bălănică <mariobalanica02@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
+ *
|
||||
+ **/
|
||||
+
|
||||
+#ifndef __MEMORY_ATTRIBUTE_MANAGER_FORMSET_H__
|
||||
+#define __MEMORY_ATTRIBUTE_MANAGER_FORMSET_H__
|
||||
+
|
||||
+#define MEMORY_ATTRIBUTE_MANAGER_FORMSET_GUID \
|
||||
+ { 0xefab3427, 0x4793, 0x4e9e, { 0xaa, 0x29, 0x88, 0x0c, 0x9a, 0x77, 0x5b, 0x5f } }
|
||||
+
|
||||
+extern EFI_GUID gMemoryAttributeManagerFormSetGuid;
|
||||
+
|
||||
+#endif // __MEMORY_ATTRIBUTE_MANAGER_FORMSET_H__
|
||||
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
|
||||
index 9c549ac7..99762f20 100644
|
||||
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
|
||||
@@ -736,6 +736,11 @@
|
||||
#
|
||||
Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.inf
|
||||
|
||||
+ #
|
||||
+ # EFI Memory Attribute Protocol Manager
|
||||
+ #
|
||||
+ Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
+
|
||||
#
|
||||
# UEFI application (Shell Embedded Boot Loader)
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf b/Platform/RaspberryPi/RPi3/RPi3.fdf
|
||||
index 3c569f57..ae1e0628 100644
|
||||
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
|
||||
@@ -230,6 +230,11 @@ READ_LOCK_STATUS = TRUE
|
||||
INF FatPkg/EnhancedFatDxe/Fat.inf
|
||||
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
|
||||
|
||||
+ #
|
||||
+ # EFI Memory Attribute Protocol Manager
|
||||
+ #
|
||||
+ INF Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
+
|
||||
#
|
||||
# UEFI application (Shell Embedded Boot Loader)
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
index ba839fd1..a48092c1 100644
|
||||
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
@@ -782,6 +782,11 @@
|
||||
#
|
||||
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
|
||||
|
||||
+ #
|
||||
+ # EFI Memory Attribute Protocol Manager
|
||||
+ #
|
||||
+ Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
+
|
||||
#
|
||||
# UEFI application (Shell Embedded Boot Loader)
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4/RPi4.fdf
|
||||
index 81692776..4f2fc5bd 100644
|
||||
--- a/Platform/RaspberryPi/RPi4/RPi4.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi4/RPi4.fdf
|
||||
@@ -227,6 +227,11 @@ READ_LOCK_STATUS = TRUE
|
||||
INF FatPkg/EnhancedFatDxe/Fat.inf
|
||||
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
|
||||
|
||||
+ #
|
||||
+ # EFI Memory Attribute Protocol Manager
|
||||
+ #
|
||||
+ INF Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
+
|
||||
#
|
||||
# UEFI application (Shell Embedded Boot Loader)
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index f2a1992e..15f6e1a3 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -668,6 +668,11 @@
|
||||
#
|
||||
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
|
||||
|
||||
+ #
|
||||
+ # EFI Memory Attribute Protocol Manager
|
||||
+ #
|
||||
+ Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
+
|
||||
#
|
||||
# UEFI application (Shell Embedded Boot Loader)
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index bfe6a90e..1507e39d 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -228,6 +228,11 @@ READ_LOCK_STATUS = TRUE
|
||||
INF FatPkg/EnhancedFatDxe/Fat.inf
|
||||
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
|
||||
|
||||
+ #
|
||||
+ # EFI Memory Attribute Protocol Manager
|
||||
+ #
|
||||
+ INF Platform/RaspberryPi/Drivers/MemoryAttributeManagerDxe/MemoryAttributeManagerDxe.inf
|
||||
+
|
||||
#
|
||||
# UEFI application (Shell Embedded Boot Loader)
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
|
||||
index d0025cf6..0c636cbf 100644
|
||||
--- a/Platform/RaspberryPi/RaspberryPi.dec
|
||||
+++ b/Platform/RaspberryPi/RaspberryPi.dec
|
||||
@@ -26,6 +26,7 @@
|
||||
gRaspberryPiTokenSpaceGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
|
||||
gRaspberryPiEventResetGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB4, 0xB4, 0xE4, 0xD4, 0xB4}}
|
||||
gConfigDxeFormSetGuid = {0xCD7CC258, 0x31DB, 0x22E6, {0x9F, 0x22, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
|
||||
+ gMemoryAttributeManagerFormSetGuid = { 0xefab3427, 0x4793, 0x4e9e, { 0xaa, 0x29, 0x88, 0x0c, 0x9a, 0x77, 0x5b, 0x5f } }
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
#
|
||||
@@ -75,3 +76,4 @@
|
||||
gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000022
|
||||
gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate|0|UINT32|0x00000023
|
||||
gRaspberryPiTokenSpaceGuid.PcdXhciReload|0|UINT32|0x00000024
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdMemoryAttributeEnabledDefault|TRUE|BOOLEAN|0x00000025
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
From 8d8d28f2e5f2c2d0ceb8ac6695575608d6d3eda5 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 5 Jan 2024 19:17:57 +0200
|
||||
Subject: [PATCH 12/16] Platform/RPi5: Enable RNG
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
Platform/RaspberryPi/RPi4/RPi4.dsc | 5 +++++
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 7 +++++-
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 2 +-
|
||||
Silicon/Broadcom/Bcm283x/Bcm283x.dec | 1 +
|
||||
.../Drivers/Bcm2838RngDxe/Bcm2838RngDxe.c | 14 +++++++-----
|
||||
.../Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf | 2 +-
|
||||
.../Include/IndustryStandard/Bcm2838Rng.h | 22 ++++++++-----------
|
||||
7 files changed, 32 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
index a48092c1..02aae204 100644
|
||||
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
|
||||
@@ -461,6 +461,11 @@
|
||||
#
|
||||
gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress|0xfe00b880
|
||||
|
||||
+ #
|
||||
+ # RNG
|
||||
+ #
|
||||
+ gBcm283xTokenSpaceGuid.PcdBcm2838RngBaseAddress|0x7e104000
|
||||
+
|
||||
#
|
||||
# Fixed CPU settings.
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 15f6e1a3..4f128fe0 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -438,6 +438,11 @@
|
||||
#
|
||||
gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress|0x107c013880
|
||||
|
||||
+ #
|
||||
+ # RNG
|
||||
+ #
|
||||
+ gBcm283xTokenSpaceGuid.PcdBcm2838RngBaseAddress|0x107d208000
|
||||
+
|
||||
#
|
||||
# RP1 BAR1 preconfigured by the VPU
|
||||
#
|
||||
@@ -643,7 +648,7 @@
|
||||
#
|
||||
# RNG
|
||||
#
|
||||
- # Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
|
||||
+ Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
|
||||
|
||||
#
|
||||
# PCI Support
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 1507e39d..4a5a05f6 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -278,7 +278,7 @@ READ_LOCK_STATUS = TRUE
|
||||
#
|
||||
# RNG
|
||||
#
|
||||
- # INF Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
|
||||
+ INF Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
|
||||
|
||||
#
|
||||
# PCI Support
|
||||
diff --git a/Silicon/Broadcom/Bcm283x/Bcm283x.dec b/Silicon/Broadcom/Bcm283x/Bcm283x.dec
|
||||
index 5b839b00..c4f40216 100644
|
||||
--- a/Silicon/Broadcom/Bcm283x/Bcm283x.dec
|
||||
+++ b/Silicon/Broadcom/Bcm283x/Bcm283x.dec
|
||||
@@ -21,3 +21,4 @@
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress|0x0|UINT32|0x00000001
|
||||
+ gBcm283xTokenSpaceGuid.PcdBcm2838RngBaseAddress|0x0|UINT64|0x00000002
|
||||
diff --git a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.c b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.c
|
||||
index 5737876e..ec4ecc0a 100644
|
||||
--- a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.c
|
||||
+++ b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.c
|
||||
@@ -24,6 +24,8 @@
|
||||
#define RNG_WARMUP_COUNT 0x40000
|
||||
#define RNG_MAX_RETRIES 0x100 // arbitrary upper bound
|
||||
|
||||
+STATIC EFI_PHYSICAL_ADDRESS mRngBase;
|
||||
+
|
||||
/**
|
||||
Returns information about the random number generation implementation.
|
||||
|
||||
@@ -110,7 +112,7 @@ Bcm2838RngReadValue (
|
||||
|
||||
ASSERT (Val != NULL);
|
||||
|
||||
- Avail = MmioRead32 (RNG_FIFO_COUNT) & RNG_FIFO_DATA_AVAIL_MASK;
|
||||
+ Avail = MmioRead32 (mRngBase + RNG_FIFO_COUNT) & RNG_FIFO_DATA_AVAIL_MASK;
|
||||
|
||||
//
|
||||
// If we don't have a value ready, wait 1 us and retry.
|
||||
@@ -131,13 +133,13 @@ Bcm2838RngReadValue (
|
||||
//
|
||||
for (i = 0; Avail < 1 && i < RNG_MAX_RETRIES; i++) {
|
||||
MicroSecondDelay (1);
|
||||
- Avail = MmioRead32 (RNG_FIFO_COUNT) & RNG_FIFO_DATA_AVAIL_MASK;
|
||||
+ Avail = MmioRead32 (mRngBase + RNG_FIFO_COUNT) & RNG_FIFO_DATA_AVAIL_MASK;
|
||||
}
|
||||
if (Avail < 1) {
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
||||
- *Val = MmioRead32 (RNG_FIFO_DATA);
|
||||
+ *Val = MmioRead32 (mRngBase + RNG_FIFO_DATA);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -246,6 +248,8 @@ Bcm2838RngEntryPoint (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
+ mRngBase = PcdGet64 (PcdBcm2838RngBaseAddress);
|
||||
+
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
|
||||
&gEfiRngProtocolGuid, &mBcm2838RngProtocol,
|
||||
NULL);
|
||||
@@ -257,7 +261,7 @@ Bcm2838RngEntryPoint (
|
||||
// This results in the RNG holding off from populating any value into the
|
||||
// FIFO until the value below has been reached in RNG_BIT_COUNT.
|
||||
//
|
||||
- MmioWrite32 (RNG_BIT_COUNT_THRESHOLD, RNG_WARMUP_COUNT);
|
||||
+ MmioWrite32 (mRngBase + RNG_BIT_COUNT_THRESHOLD, RNG_WARMUP_COUNT);
|
||||
|
||||
//
|
||||
// We would disable RNG interrupts here... if we had access to the datasheet.
|
||||
@@ -278,7 +282,7 @@ Bcm2838RngEntryPoint (
|
||||
// instead of single bits, which may be unintended. But since we don't have
|
||||
// any public documentation on what each of these bits do, we follow suit.
|
||||
//
|
||||
- MmioWrite32 (RNG_CTRL,
|
||||
+ MmioWrite32 (mRngBase + RNG_CTRL,
|
||||
RNG_CTRL_ENABLE_MASK | (3 << RNG_CTRL_SAMPLE_RATE_DIVISOR_SHIFT));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
diff --git a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
|
||||
index fdc1b257..dadd5765 100644
|
||||
--- a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
|
||||
+++ b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
|
||||
@@ -40,7 +40,7 @@
|
||||
gEfiRngAlgorithmRaw
|
||||
|
||||
[FixedPcd]
|
||||
- gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
|
||||
+ gBcm283xTokenSpaceGuid.PcdBcm2838RngBaseAddress
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2838Rng.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2838Rng.h
|
||||
index 003866fa..8b321151 100644
|
||||
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2838Rng.h
|
||||
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2838Rng.h
|
||||
@@ -9,19 +9,15 @@
|
||||
#ifndef BCM2838_RNG_H__
|
||||
#define BCM2838_RNG_H__
|
||||
|
||||
-#define BCM2838_RNG_OFFSET 0x00104000
|
||||
-#define RNG_BASE_ADDRESS ((FixedPcdGet64 (PcdBcm283xRegistersAddress)) \
|
||||
- + BCM2838_RNG_OFFSET)
|
||||
-
|
||||
-#define RNG_CTRL (RNG_BASE_ADDRESS + 0x0)
|
||||
-#define RNG_STATUS (RNG_BASE_ADDRESS + 0x4)
|
||||
-#define RNG_DATA (RNG_BASE_ADDRESS + 0x8)
|
||||
-#define RNG_BIT_COUNT (RNG_BASE_ADDRESS + 0xc)
|
||||
-#define RNG_BIT_COUNT_THRESHOLD (RNG_BASE_ADDRESS + 0x10)
|
||||
-#define RNG_INT_STATUS (RNG_BASE_ADDRESS + 0x18)
|
||||
-#define RNG_INT_ENABLE (RNG_BASE_ADDRESS + 0x1c)
|
||||
-#define RNG_FIFO_DATA (RNG_BASE_ADDRESS + 0x20)
|
||||
-#define RNG_FIFO_COUNT (RNG_BASE_ADDRESS + 0x24)
|
||||
+#define RNG_CTRL 0x0
|
||||
+#define RNG_STATUS 0x4
|
||||
+#define RNG_DATA 0x8
|
||||
+#define RNG_BIT_COUNT 0xc
|
||||
+#define RNG_BIT_COUNT_THRESHOLD 0x10
|
||||
+#define RNG_INT_STATUS 0x18
|
||||
+#define RNG_INT_ENABLE 0x1c
|
||||
+#define RNG_FIFO_DATA 0x20
|
||||
+#define RNG_FIFO_COUNT 0x24
|
||||
|
||||
#define RNG_CTRL_ENABLE_MASK 0x1fff
|
||||
#define RNG_CTRL_SAMPLE_RATE_DIVISOR_SHIFT 13 // Unmasked bits from above
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
From cc780563b58b849e002358eaccf4afabcc6065da Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 5 Jan 2024 19:30:54 +0200
|
||||
Subject: [PATCH 13/16] =?UTF-8?q?=EF=BB=BFPlatform/RPi5:=20Add=20FDT=20sys?=
|
||||
=?UTF-8?q?tem=20table=20support?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c | 62 +++++++++-------
|
||||
.../RaspberryPi/Drivers/FdtDxe/FdtDxe.inf | 4 +-
|
||||
.../RPi5/Drivers/RpiPlatformDxe/ConfigTable.c | 17 +++++
|
||||
.../Drivers/RpiPlatformDxe/RpiPlatformDxe.inf | 3 +
|
||||
.../RpiPlatformDxe/RpiPlatformDxeHii.uni | 12 +++-
|
||||
.../RpiPlatformDxe/RpiPlatformDxeHii.vfr | 71 ++++++++++++-------
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 11 ++-
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 2 +-
|
||||
8 files changed, 125 insertions(+), 57 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
|
||||
index fadf262f..5ad3c708 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
|
||||
@@ -9,8 +9,11 @@
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
+#include <Library/BoardInfoLib.h>
|
||||
+#include <Library/BoardRevisionHelperLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/DxeServicesLib.h>
|
||||
+#include <Library/FdtPlatformLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
@@ -22,6 +25,7 @@
|
||||
STATIC VOID *mFdtImage;
|
||||
|
||||
STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
|
||||
+STATIC UINT32 mBoardRevision;
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
@@ -461,9 +465,15 @@ FdtDxeInitialize (
|
||||
(VOID**)&mFwProtocol);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
- FdtImage = (VOID*)(UINTN)PcdGet32 (PcdFdtBaseAddress);
|
||||
- Retval = fdt_check_header (FdtImage);
|
||||
- if (Retval != 0) {
|
||||
+ Status = BoardInfoGetRevisionCode (&mBoardRevision);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR,
|
||||
+ "%a: Failed to get board revision code. Status=%r\n",
|
||||
+ __func__, Status));
|
||||
+ }
|
||||
+
|
||||
+ FdtImage = FdtPlatformGetBase ();
|
||||
+ if (FdtImage == NULL) {
|
||||
/*
|
||||
* Any one of:
|
||||
* - Invalid config.txt device_tree_address (not PcdFdtBaseAddress)
|
||||
@@ -497,39 +507,41 @@ FdtDxeInitialize (
|
||||
* These are all best-effort.
|
||||
*/
|
||||
|
||||
- Status = SanitizePSCI ();
|
||||
- if (EFI_ERROR (Status)) {
|
||||
- Print (L"Failed to sanitize PSCI: %r\n", Status);
|
||||
- }
|
||||
-
|
||||
Status = CleanMemoryNodes ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
- Print (L"Failed to clean memory nodes: %r\n", Status);
|
||||
+ DEBUG ((DEBUG_ERROR, "Failed to clean memory nodes: %r\n", Status));
|
||||
}
|
||||
|
||||
Status = CleanSimpleFramebuffer ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
- Print (L"Failed to clean frame buffer: %r\n", Status);
|
||||
+ DEBUG ((DEBUG_ERROR, "Failed to clean frame buffer: %r\n", Status));
|
||||
}
|
||||
|
||||
- Status = FixEthernetAliases ();
|
||||
- if (EFI_ERROR (Status)) {
|
||||
- Print (L"Failed to fix ethernet aliases: %r\n", Status);
|
||||
- }
|
||||
+ if (BoardRevisionGetModelFamily (mBoardRevision) < 5) {
|
||||
+ Status = SanitizePSCI ();
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "Failed to sanitize PSCI: %r\n", Status));
|
||||
+ }
|
||||
|
||||
- Status = UpdateMacAddress ();
|
||||
- if (EFI_ERROR (Status)) {
|
||||
- Print (L"Failed to update MAC address: %r\n", Status);
|
||||
- }
|
||||
+ Status = FixEthernetAliases ();
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "Failed to fix ethernet aliases: %r\n", Status));
|
||||
+ }
|
||||
|
||||
- Status = AddUsbCompatibleProperty ();
|
||||
- if (EFI_ERROR (Status)) {
|
||||
- Print (L"Failed to update USB compatible properties: %r\n", Status);
|
||||
- }
|
||||
+ Status = UpdateMacAddress ();
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "Failed to update MAC address: %r\n", Status));
|
||||
+ }
|
||||
|
||||
- SyncPcie ();
|
||||
- if (EFI_ERROR (Status)) {
|
||||
- Print (L"Failed to update PCIe address ranges: %r\n", Status);
|
||||
+ Status = AddUsbCompatibleProperty ();
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "Failed to update USB compatible properties: %r\n", Status));
|
||||
+ }
|
||||
+
|
||||
+ Status = SyncPcie ();
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ DEBUG ((DEBUG_ERROR, "Failed to update PCIe address ranges: %r\n", Status));
|
||||
+ }
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Installed devicetree at address %p\n", mFdtImage));
|
||||
diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
index 90e138af..1ea2fe40 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
+++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
@@ -27,9 +27,12 @@
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
+ BoardInfoLib
|
||||
+ BoardRevisionHelperLib
|
||||
DebugLib
|
||||
DxeServicesLib
|
||||
FdtLib
|
||||
+ FdtPlatformLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
@@ -50,7 +53,6 @@
|
||||
gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen
|
||||
gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr
|
||||
|
||||
-
|
||||
[Pcd]
|
||||
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
|
||||
gRaspberryPiTokenSpaceGuid.PcdXhciReload
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/ConfigTable.c b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/ConfigTable.c
|
||||
index da86e2e0..9aadb325 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/ConfigTable.c
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/ConfigTable.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Protocol/AcpiSystemDescriptionTable.h>
|
||||
#include <RpiPlatformVarStoreData.h>
|
||||
+#include <ConfigVars.h>
|
||||
|
||||
#include "ConfigTable.h"
|
||||
|
||||
@@ -108,6 +109,12 @@ ApplyConfigTableVariables (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
+ if (PcdGet32 (PcdSystemTableMode) != SYSTEM_TABLE_MODE_ACPI
|
||||
+ && PcdGet32 (PcdSystemTableMode) != SYSTEM_TABLE_MODE_BOTH) {
|
||||
+ // FDT is taken care of by FdtDxe.
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
Status = LocateAndInstallAcpiFromFvConditional (&mAcpiTableFile, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Failed to install ACPI tables!\n"));
|
||||
@@ -128,6 +135,7 @@ SetupConfigTableVariables (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
+ UINT32 Var32;
|
||||
|
||||
AcpiSdCompatMode.Value = ACPI_SD_COMPAT_MODE_DEFAULT;
|
||||
AcpiSdLimitUhs.Value = ACPI_SD_LIMIT_UHS_DEFAULT;
|
||||
@@ -159,4 +167,13 @@ SetupConfigTableVariables (
|
||||
&AcpiSdLimitUhs);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
+
|
||||
+ Size = sizeof (UINT32);
|
||||
+ Status = gRT->GetVariable (L"SystemTableMode",
|
||||
+ &gRpiPlatformFormSetGuid,
|
||||
+ NULL, &Size, &Var32);
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ Status = PcdSet32S (PcdSystemTableMode, PcdGet32 (PcdSystemTableMode));
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ }
|
||||
}
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
index b1cb4303..6bb48c3f 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
@@ -48,6 +48,9 @@
|
||||
gEfiAcpiSdtProtocolGuid ## CONSUMES
|
||||
gBrcmStbSdhciDeviceProtocolGuid ## PRODUCES
|
||||
|
||||
+[Pcd]
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
|
||||
+
|
||||
[Depex]
|
||||
gEfiVariableArchProtocolGuid
|
||||
AND gEfiVariableWriteArchProtocolGuid
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.uni b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.uni
|
||||
index 7f362922..5cb460f6 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.uni
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.uni
|
||||
@@ -17,10 +17,16 @@
|
||||
/*
|
||||
* ACPI / Device Tree configuration
|
||||
*/
|
||||
-#string STR_CONFIG_TABLE_FORM_TITLE #language en-US "ACPI / Device Tree"
|
||||
-#string STR_CONFIG_TABLE_FORM_HELP #language en-US "Configure the ACPI and Device Tree system tables support."
|
||||
+#string STR_SYSTEM_TABLE_FORM_TITLE #language en-US "ACPI / Device Tree"
|
||||
+#string STR_SYSTEM_TABLE_FORM_HELP #language en-US "Configure the ACPI and Device Tree system tables support."
|
||||
|
||||
-#string STR_CONFIG_TABLE_ACPI_SUBTITLE #language en-US "ACPI Configuration"
|
||||
+#string STR_SYSTEM_TABLE_MODE_PROMPT #language en-US "System Table Mode"
|
||||
+#string STR_SYSTEM_TABLE_MODE_HELP #language en-US "Choose what system tables to expose to the OS.\n\nACPI - provides basic hardware support (USB, SD) for most OS/kernel versions.\n\nDevice Tree - provides extensive hardware support specific to a kernel version.\nUEFI hands over the DTB and overlays passed by the VPU firmware, which reside in the boot partition.\n\nIf both are exposed, the OS will decide which one to use."
|
||||
+#string STR_SYSTEM_TABLE_MODE_ACPI #language en-US "ACPI"
|
||||
+#string STR_SYSTEM_TABLE_MODE_FDT #language en-US "Device Tree"
|
||||
+#string STR_SYSTEM_TABLE_MODE_ACPI_FDT #language en-US "Both"
|
||||
+
|
||||
+#string STR_SYSTEM_TABLE_ACPI_SUBTITLE #language en-US "ACPI Configuration"
|
||||
|
||||
#string STR_ACPI_SD_SUBTITLE #language en-US "Broadcom SD Host Controller"
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.vfr b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.vfr
|
||||
index 65163f10..e5ee4b3e 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.vfr
|
||||
+++ b/Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxeHii.vfr
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Guid/HiiPlatformSetupFormset.h>
|
||||
#include <Guid/RpiPlatformFormSetGuid.h>
|
||||
#include <RpiPlatformVarStoreData.h>
|
||||
+#include <ConfigVars.h>
|
||||
|
||||
#include "ConfigTable.h"
|
||||
|
||||
@@ -19,15 +20,20 @@ formset
|
||||
help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
|
||||
classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
|
||||
|
||||
+ efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA,
|
||||
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
+ name = SystemTableMode,
|
||||
+ guid = RPI_PLATFORM_FORMSET_GUID;
|
||||
+
|
||||
efivarstore ACPI_SD_COMPAT_MODE_VARSTORE_DATA,
|
||||
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
- name = AcpiSdCompatMode,
|
||||
- guid = RPI_PLATFORM_FORMSET_GUID;
|
||||
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
+ name = AcpiSdCompatMode,
|
||||
+ guid = RPI_PLATFORM_FORMSET_GUID;
|
||||
|
||||
efivarstore ACPI_SD_LIMIT_UHS_VARSTORE_DATA,
|
||||
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
- name = AcpiSdLimitUhs,
|
||||
- guid = RPI_PLATFORM_FORMSET_GUID;
|
||||
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
+ name = AcpiSdLimitUhs,
|
||||
+ guid = RPI_PLATFORM_FORMSET_GUID;
|
||||
|
||||
form formid = 1,
|
||||
title = STRING_TOKEN(STR_FORM_SET_TITLE);
|
||||
@@ -36,32 +42,45 @@ formset
|
||||
subtitle text = STRING_TOKEN(STR_NULL_STRING);
|
||||
|
||||
goto 0x1000,
|
||||
- prompt = STRING_TOKEN(STR_CONFIG_TABLE_FORM_TITLE),
|
||||
- help = STRING_TOKEN(STR_CONFIG_TABLE_FORM_HELP);
|
||||
+ prompt = STRING_TOKEN(STR_SYSTEM_TABLE_FORM_TITLE),
|
||||
+ help = STRING_TOKEN(STR_SYSTEM_TABLE_FORM_HELP);
|
||||
endform;
|
||||
|
||||
form formid = 0x1000,
|
||||
- title = STRING_TOKEN(STR_CONFIG_TABLE_FORM_TITLE);
|
||||
+ title = STRING_TOKEN(STR_SYSTEM_TABLE_FORM_TITLE);
|
||||
+
|
||||
+ oneof varid = SystemTableMode.Mode,
|
||||
+ prompt = STRING_TOKEN(STR_SYSTEM_TABLE_MODE_PROMPT),
|
||||
+ help = STRING_TOKEN(STR_SYSTEM_TABLE_MODE_HELP),
|
||||
+ flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
|
||||
+ default = SYSTEM_TABLE_MODE_ACPI,
|
||||
+ option text = STRING_TOKEN(STR_SYSTEM_TABLE_MODE_ACPI), value = SYSTEM_TABLE_MODE_ACPI, flags = 0;
|
||||
+ option text = STRING_TOKEN(STR_SYSTEM_TABLE_MODE_FDT), value = SYSTEM_TABLE_MODE_DT, flags = 0;
|
||||
+ option text = STRING_TOKEN(STR_SYSTEM_TABLE_MODE_ACPI_FDT), value = SYSTEM_TABLE_MODE_BOTH, flags = 0;
|
||||
+ endoneof;
|
||||
|
||||
- subtitle text = STRING_TOKEN(STR_CONFIG_TABLE_ACPI_SUBTITLE);
|
||||
+ suppressif (get(SystemTableMode.Mode) != SYSTEM_TABLE_MODE_ACPI AND get(SystemTableMode.Mode) != SYSTEM_TABLE_MODE_BOTH);
|
||||
+ subtitle text = STRING_TOKEN(STR_NULL_STRING);
|
||||
+ subtitle text = STRING_TOKEN(STR_SYSTEM_TABLE_ACPI_SUBTITLE);
|
||||
|
||||
- subtitle text = STRING_TOKEN(STR_NULL_STRING);
|
||||
- subtitle text = STRING_TOKEN(STR_ACPI_SD_SUBTITLE);
|
||||
+ subtitle text = STRING_TOKEN(STR_NULL_STRING);
|
||||
+ subtitle text = STRING_TOKEN(STR_ACPI_SD_SUBTITLE);
|
||||
|
||||
- oneof varid = AcpiSdCompatMode.Value,
|
||||
- prompt = STRING_TOKEN(STR_ACPI_SD_COMPAT_MODE_PROMPT),
|
||||
- help = STRING_TOKEN(STR_ACPI_SD_COMPAT_MODE_HELP),
|
||||
- flags = NUMERIC_SIZE_1 | INTERACTIVE | RESET_REQUIRED,
|
||||
- default = ACPI_SD_COMPAT_MODE_DEFAULT,
|
||||
- option text = STRING_TOKEN(STR_ACPI_SD_COMPAT_BRCMSTB_BAYTRAIL), value = ACPI_SD_COMPAT_MODE_BRCMSTB_BAYTRAIL, flags = 0;
|
||||
- option text = STRING_TOKEN(STR_ACPI_SD_COMPAT_FULL_BAYTRAIL), value = ACPI_SD_COMPAT_MODE_FULL_BAYTRAIL, flags = 0;
|
||||
- endoneof;
|
||||
+ oneof varid = AcpiSdCompatMode.Value,
|
||||
+ prompt = STRING_TOKEN(STR_ACPI_SD_COMPAT_MODE_PROMPT),
|
||||
+ help = STRING_TOKEN(STR_ACPI_SD_COMPAT_MODE_HELP),
|
||||
+ flags = NUMERIC_SIZE_1 | INTERACTIVE | RESET_REQUIRED,
|
||||
+ default = ACPI_SD_COMPAT_MODE_DEFAULT,
|
||||
+ option text = STRING_TOKEN(STR_ACPI_SD_COMPAT_BRCMSTB_BAYTRAIL), value = ACPI_SD_COMPAT_MODE_BRCMSTB_BAYTRAIL, flags = 0;
|
||||
+ option text = STRING_TOKEN(STR_ACPI_SD_COMPAT_FULL_BAYTRAIL), value = ACPI_SD_COMPAT_MODE_FULL_BAYTRAIL, flags = 0;
|
||||
+ endoneof;
|
||||
|
||||
- checkbox varid = AcpiSdLimitUhs.Value,
|
||||
- prompt = STRING_TOKEN(STR_ACPI_SD_LIMIT_UHS_PROMPT),
|
||||
- help = STRING_TOKEN(STR_ACPI_SD_LIMIT_UHS_HELP),
|
||||
- flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
|
||||
- default = ACPI_SD_LIMIT_UHS_DEFAULT,
|
||||
- endcheckbox;
|
||||
+ checkbox varid = AcpiSdLimitUhs.Value,
|
||||
+ prompt = STRING_TOKEN(STR_ACPI_SD_LIMIT_UHS_PROMPT),
|
||||
+ help = STRING_TOKEN(STR_ACPI_SD_LIMIT_UHS_HELP),
|
||||
+ flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
|
||||
+ default = ACPI_SD_LIMIT_UHS_DEFAULT,
|
||||
+ endcheckbox;
|
||||
+ endif;
|
||||
endform;
|
||||
endformset;
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 4f128fe0..63e86be3 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -474,6 +474,15 @@
|
||||
#
|
||||
gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|L"ResetDelay"|gRaspberryPiTokenSpaceGuid|0x0|0
|
||||
|
||||
+ #
|
||||
+ # Device Tree and ACPI selection.
|
||||
+ #
|
||||
+ # 0 - SYSTEM_TABLE_MODE_ACPI (default)
|
||||
+ # 1 - SYSTEM_TABLE_MODE_BOTH
|
||||
+ # 2 - SYSTEM_TABLE_MODE_DT
|
||||
+ #
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gRpiPlatformFormSetGuid|0x0|0
|
||||
+
|
||||
#
|
||||
# Common UEFI ones.
|
||||
#
|
||||
@@ -569,7 +578,7 @@
|
||||
ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
|
||||
Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
- # Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
+ Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
|
||||
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
|
||||
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 4a5a05f6..a00b3d98 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -215,7 +215,7 @@ READ_LOCK_STATUS = TRUE
|
||||
INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
|
||||
INF Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
INF Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
- # INF Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
+ INF Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
|
||||
INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
|
||||
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
|
||||
--
|
||||
2.51.2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
From b2427c0f29a2a1d68f0dbd955dd11f832c071800 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 15 Mar 2024 03:11:25 +0200
|
||||
Subject: [PATCH 15/16] Platform/RPi5: Make AcpiTableDxe less verbose
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
No need to print the entire namespace each time a value is patched.
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 31 ++++++++++++++++++------------
|
||||
1 file changed, 19 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 58eb5dfd..e78f8c85 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -48,6 +48,20 @@
|
||||
DEFINE TFA_BUILD_BL31 = $(TFA_BUILD_ARTIFACTS)/bl31.bin
|
||||
!endif
|
||||
|
||||
+ #
|
||||
+ # DEBUG_ASSERT_ENABLED 0x01
|
||||
+ # DEBUG_PRINT_ENABLED 0x02
|
||||
+ # DEBUG_CODE_ENABLED 0x04
|
||||
+ # CLEAR_MEMORY_ENABLED 0x08
|
||||
+ # ASSERT_BREAKPOINT_ENABLED 0x10
|
||||
+ # ASSERT_DEADLOOP_ENABLED 0x20
|
||||
+ #
|
||||
+!if $(TARGET) == RELEASE
|
||||
+ DEFINE DEBUG_PROPERTY_MASK = 0x21
|
||||
+!else
|
||||
+ DEFINE DEBUG_PROPERTY_MASK = 0x2f
|
||||
+!endif
|
||||
+
|
||||
################################################################################
|
||||
#
|
||||
# Library Class section - list of all Library Classes needed by this Platform.
|
||||
@@ -291,17 +305,7 @@
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
|
||||
|
||||
- # DEBUG_ASSERT_ENABLED 0x01
|
||||
- # DEBUG_PRINT_ENABLED 0x02
|
||||
- # DEBUG_CODE_ENABLED 0x04
|
||||
- # CLEAR_MEMORY_ENABLED 0x08
|
||||
- # ASSERT_BREAKPOINT_ENABLED 0x10
|
||||
- # ASSERT_DEADLOOP_ENABLED 0x20
|
||||
-!if $(TARGET) == RELEASE
|
||||
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x21
|
||||
-!else
|
||||
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f
|
||||
-!endif
|
||||
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|$(DEBUG_PROPERTY_MASK)
|
||||
|
||||
# DEBUG_INIT 0x00000001 // Initialization
|
||||
# DEBUG_WARN 0x00000002 // Warnings
|
||||
@@ -594,7 +598,10 @@
|
||||
#
|
||||
# ACPI Support
|
||||
#
|
||||
- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
|
||||
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf {
|
||||
+ <PcdsFixedAtBuild>
|
||||
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|$(DEBUG_PROPERTY_MASK) & ~0x04
|
||||
+ }
|
||||
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
|
||||
Platform/RaspberryPi/RPi5/AcpiTables/AcpiTables.inf
|
||||
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From 8e1779b538bcc1e6dc68d7df625394f933651d7a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?=
|
||||
<mariobalanica02@gmail.com>
|
||||
Date: Fri, 15 Mar 2024 03:12:05 +0200
|
||||
Subject: [PATCH 16/16] Platform/RPi5: Add SATA drivers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
|
||||
---
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 7 +++++++
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 7 +++++++
|
||||
2 files changed, 14 insertions(+)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index e78f8c85..ff9f5010 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -695,6 +695,13 @@
|
||||
#
|
||||
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
|
||||
|
||||
+ #
|
||||
+ # AHCI Support
|
||||
+ #
|
||||
+ MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
|
||||
+ MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
|
||||
+ MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
|
||||
+
|
||||
#
|
||||
# EFI Memory Attribute Protocol Manager
|
||||
#
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 552160a0..8d79e453 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -299,6 +299,13 @@ READ_LOCK_STATUS = TRUE
|
||||
#
|
||||
INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
|
||||
|
||||
+ #
|
||||
+ # AHCI Support
|
||||
+ #
|
||||
+ INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
|
||||
+ INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
|
||||
+ INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
|
||||
+
|
||||
#
|
||||
# SCSI Bus and Disk Driver
|
||||
#
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
From 4f922b40c69cac16226a8e4540f678275e1480fd Mon Sep 17 00:00:00 2001
|
||||
From: MattP <63603528+NumberOneGit@users.noreply.github.com>
|
||||
Date: Mon, 5 May 2025 21:49:18 -0400
|
||||
Subject: [PATCH 17/29] Add additional BCM2712 boards
|
||||
|
||||
---
|
||||
.../BoardRevisionHelperLib/BoardRevisionHelperLib.c | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c b/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c
|
||||
index 032853aa..40143c5b 100644
|
||||
--- a/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c
|
||||
+++ b/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c
|
||||
@@ -58,7 +58,10 @@ BoardRevisionGetModelFamily (
|
||||
case 0x14: // Raspberry Pi Computer Module 4
|
||||
return 4;
|
||||
case 0x17: // Raspberry Pi 5 Model B
|
||||
- return 5;
|
||||
+ case 0x18: // Compute Module 5
|
||||
+ case 0x19: // Raspberry Pi 500
|
||||
+ case 0x1a: // Compute Module 5 Lite
|
||||
+ return 5;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -106,6 +109,12 @@ BoardRevisionGetModelName (
|
||||
return "Raspberry Pi Compute Module 4";
|
||||
case 0x17:
|
||||
return "Raspberry Pi 5 Model B";
|
||||
+ case 0x18:
|
||||
+ return "Raspberry Pi Compute Module 5";
|
||||
+ case 0x19:
|
||||
+ return "Raspberry Pi 500"
|
||||
+ case 0x1a:
|
||||
+ return "Raspberry Pi Compute Module 5 Lite"
|
||||
}
|
||||
}
|
||||
return "Unknown Raspberry Pi Model";
|
||||
--
|
||||
2.51.2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
From deaab4b9f67f7fbfd982a7f43485c2bceba1e9b9 Mon Sep 17 00:00:00 2001
|
||||
From: MattP <63603528+NumberOneGit@users.noreply.github.com>
|
||||
Date: Thu, 8 May 2025 14:40:25 -0400
|
||||
Subject: [PATCH 19/29] Update DisplayDxe.c
|
||||
|
||||
Fill reserved bit to enable FB
|
||||
---
|
||||
Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
|
||||
index 3eba98e5..800f7a90 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
|
||||
@@ -211,6 +211,7 @@ ClearScreen (
|
||||
Fill.Red = 0x00;
|
||||
Fill.Green = 0x00;
|
||||
Fill.Blue = 0x00;
|
||||
+ Fill.Reserved = 0xFF;
|
||||
This->Blt (This, &Fill, EfiBltVideoFill,
|
||||
0, 0, 0, 0, This->Mode->Info->HorizontalResolution,
|
||||
This->Mode->Info->VerticalResolution,
|
||||
@@ -319,6 +320,7 @@ DisplayBlt (
|
||||
|
||||
for (i = 0; i < Height; i++) {
|
||||
VidBuf = POS_TO_FB (DestinationX, DestinationY + i);
|
||||
+ ((EFI_GRAPHICS_OUTPUT_BLT_PIXEL*)BltBuf)->Reserved = 0xFF;
|
||||
|
||||
SetMem32 (VidBuf, Width * PI3_BYTES_PER_PIXEL, *(UINT32*)BltBuf);
|
||||
}
|
||||
@@ -345,6 +347,14 @@ DisplayBlt (
|
||||
}
|
||||
|
||||
for (i = 0; i < Height; i++) {
|
||||
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelRow = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)
|
||||
+ ((UINTN)BltBuffer + (SourceY + i) * Delta + SourceX * PI3_BYTES_PER_PIXEL);
|
||||
+
|
||||
+ for (UINTN x = 0; x < Width; x++) {
|
||||
+ if (PixelRow[x].Reserved != 0xFF) {
|
||||
+ PixelRow[x].Reserved = 0xFF;
|
||||
+ }
|
||||
+ }
|
||||
VidBuf = POS_TO_FB (DestinationX, DestinationY + i);
|
||||
BltBuf = (UINT8*)((UINTN)BltBuffer + (SourceY + i) * Delta +
|
||||
SourceX * PI3_BYTES_PER_PIXEL);
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
From 9b95eaff168da17f97a8c014b5461d449bc93bea Mon Sep 17 00:00:00 2001
|
||||
From: MattP <63603528+NumberOneGit@users.noreply.github.com>
|
||||
Date: Sat, 10 May 2025 03:25:34 -0400
|
||||
Subject: [PATCH 20/29] Update BoardRevisionHelperLib.c
|
||||
|
||||
fix line ending
|
||||
---
|
||||
.../Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c b/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c
|
||||
index 40143c5b..24d8a801 100644
|
||||
--- a/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c
|
||||
+++ b/Platform/RaspberryPi/Library/BoardRevisionHelperLib/BoardRevisionHelperLib.c
|
||||
@@ -112,9 +112,9 @@ BoardRevisionGetModelName (
|
||||
case 0x18:
|
||||
return "Raspberry Pi Compute Module 5";
|
||||
case 0x19:
|
||||
- return "Raspberry Pi 500"
|
||||
- case 0x1a:
|
||||
- return "Raspberry Pi Compute Module 5 Lite"
|
||||
+ return "Raspberry Pi 500";
|
||||
+ case 0x1A:
|
||||
+ return "Raspberry Pi Compute Module 5 Lite";
|
||||
}
|
||||
}
|
||||
return "Unknown Raspberry Pi Model";
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From 5654030569418c46e5a46066c495d4fad852b4f8 Mon Sep 17 00:00:00 2001
|
||||
From: MattP <63603528+NumberOneGit@users.noreply.github.com>
|
||||
Date: Mon, 9 Jun 2025 22:19:24 -0400
|
||||
Subject: [PATCH 21/29] Adjust UART interrupt for D0
|
||||
|
||||
D0 uses a different interrupt for UART0
|
||||
---
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index ff9f5010..3aab6ea8 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -425,7 +425,7 @@
|
||||
|
||||
# UARTs
|
||||
gArmPlatformTokenSpaceGuid.PL011UartClkInHz|44000000
|
||||
- gArmPlatformTokenSpaceGuid.PL011UartInterrupt|153
|
||||
+ gArmPlatformTokenSpaceGuid.PL011UartInterrupt|152
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x107d001000
|
||||
|
||||
--
|
||||
2.51.2
|
||||
|
||||
701
packages/edk2/patches/platforms/0022-Aug-28-edk2-needed.patch
Normal file
701
packages/edk2/patches/platforms/0022-Aug-28-edk2-needed.patch
Normal file
@@ -0,0 +1,701 @@
|
||||
From e1b8435ed33b43cb6e9ae23adc24e1ce57dd57af Mon Sep 17 00:00:00 2001
|
||||
From: mattp <svidasultaresurge@gmail.com>
|
||||
Date: Tue, 8 Jul 2025 14:24:04 -0400
|
||||
Subject: [PATCH 22/29] Aug 28 edk2 needed
|
||||
|
||||
---
|
||||
.../VarBlockServiceDxe/VarBlockServiceDxe.c | 65 +++++---
|
||||
.../VarBlockServiceDxe/VarBlockServiceDxe.inf | 6 +-
|
||||
.../MemoryInitPeiLib/MemoryInitPeiLib.c | 2 +
|
||||
.../PlatformBootManagerLib/PlatformBm.c | 78 +++++++++
|
||||
.../PlatformBootManagerLib.inf | 6 +
|
||||
.../RaspberryPi/Library/ResetLib/ResetLib.c | 151 ------------------
|
||||
.../RaspberryPi/Library/ResetLib/ResetLib.inf | 45 ------
|
||||
.../PlatformLib/AArch64/RaspberryPiHelper.S | 27 ----
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 23 +--
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 4 +-
|
||||
Platform/RaspberryPi/RaspberryPi.dec | 1 -
|
||||
11 files changed, 152 insertions(+), 256 deletions(-)
|
||||
delete mode 100644 Platform/RaspberryPi/Library/ResetLib/ResetLib.c
|
||||
delete mode 100644 Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
|
||||
index 4071a3fc..bc8ab227 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include "VarBlockService.h"
|
||||
|
||||
+#include <Protocol/ResetNotification.h>
|
||||
+
|
||||
//
|
||||
// Minimum delay to enact before reset, when variables are dirty (in μs).
|
||||
// Needed to ensure that SSD-based USB 3.0 devices have time to flush their
|
||||
@@ -51,6 +53,8 @@ InstallProtocolInterfaces (
|
||||
&FvbDevice->FwVolBlockInstance,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
FvbDevice->DevicePath,
|
||||
+ &gEdkiiNvVarStoreFormattedGuid,
|
||||
+ NULL,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@@ -159,10 +163,8 @@ DoDump (
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
-EFIAPI
|
||||
DumpVars (
|
||||
- IN EFI_EVENT Event,
|
||||
- IN VOID *Context
|
||||
+ VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -200,6 +202,29 @@ DumpVars (
|
||||
mFvInstance->Dirty = FALSE;
|
||||
}
|
||||
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+DumpVarsOnEvent (
|
||||
+ IN EFI_EVENT Event,
|
||||
+ IN VOID *Context
|
||||
+ )
|
||||
+{
|
||||
+ DumpVars ();
|
||||
+}
|
||||
+
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+DumpVarsOnReset (
|
||||
+ IN EFI_RESET_TYPE ResetType,
|
||||
+ IN EFI_STATUS ResetStatus,
|
||||
+ IN UINTN DataSize,
|
||||
+ IN VOID *ResetData OPTIONAL
|
||||
+ )
|
||||
+{
|
||||
+ DumpVars ();
|
||||
+}
|
||||
|
||||
VOID
|
||||
ReadyToBootHandler (
|
||||
@@ -214,7 +239,7 @@ ReadyToBootHandler (
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_CALLBACK,
|
||||
- DumpVars,
|
||||
+ DumpVarsOnEvent,
|
||||
NULL,
|
||||
&ImageInstallEvent
|
||||
);
|
||||
@@ -227,7 +252,7 @@ ReadyToBootHandler (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
- DumpVars (NULL, NULL);
|
||||
+ DumpVars ();
|
||||
Status = gBS->CloseEvent (Event);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
@@ -238,19 +263,9 @@ InstallDumpVarEventHandlers (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
- EFI_STATUS Status;
|
||||
- EFI_EVENT ResetEvent;
|
||||
- EFI_EVENT ReadyToBootEvent;
|
||||
-
|
||||
- Status = gBS->CreateEventEx (
|
||||
- EVT_NOTIFY_SIGNAL,
|
||||
- TPL_CALLBACK,
|
||||
- DumpVars,
|
||||
- NULL,
|
||||
- &gRaspberryPiEventResetGuid,
|
||||
- &ResetEvent
|
||||
- );
|
||||
- ASSERT_EFI_ERROR (Status);
|
||||
+ EFI_STATUS Status;
|
||||
+ EFI_EVENT ReadyToBootEvent;
|
||||
+ EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotify;
|
||||
|
||||
Status = gBS->CreateEventEx (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@@ -261,6 +276,20 @@ InstallDumpVarEventHandlers (
|
||||
&ReadyToBootEvent
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
+
|
||||
+ Status = gBS->LocateProtocol (
|
||||
+ &gEfiResetNotificationProtocolGuid,
|
||||
+ NULL,
|
||||
+ (VOID **)&ResetNotify
|
||||
+ );
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ if (!EFI_ERROR (Status)) {
|
||||
+ Status = ResetNotify->RegisterResetNotify (
|
||||
+ ResetNotify,
|
||||
+ DumpVarsOnReset
|
||||
+ );
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ }
|
||||
}
|
||||
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
|
||||
index c2edb25b..d15671af 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
|
||||
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
[Packages]
|
||||
ArmPkg/ArmPkg.dec
|
||||
+ EmbeddedPkg/EmbeddedPkg.dec
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
Platform/RaspberryPi/RaspberryPi.dec
|
||||
@@ -51,8 +52,8 @@
|
||||
UefiRuntimeLib
|
||||
|
||||
[Guids]
|
||||
+ gEdkiiNvVarStoreFormattedGuid ## PRODUCES ## PROTOCOL
|
||||
gEfiEventVirtualAddressChangeGuid
|
||||
- gRaspberryPiEventResetGuid
|
||||
gEfiEventReadyToBootGuid
|
||||
|
||||
[Protocols]
|
||||
@@ -61,6 +62,7 @@
|
||||
gEfiBlockIoProtocolGuid
|
||||
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
||||
+ gEfiResetNotificationProtocolGuid
|
||||
|
||||
[FixedPcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
|
||||
@@ -85,4 +87,4 @@
|
||||
[FeaturePcd]
|
||||
|
||||
[Depex]
|
||||
- TRUE
|
||||
+ gEfiResetNotificationProtocolGuid
|
||||
diff --git a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
|
||||
index 7ba1cc56..cf9eca2f 100644
|
||||
--- a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
|
||||
+++ b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
|
||||
@@ -51,6 +51,8 @@ AddBasicMemoryRegion (
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
|
||||
+ EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTABLE |
|
||||
+ EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTABLE |
|
||||
EFI_RESOURCE_ATTRIBUTE_TESTED,
|
||||
Desc->PhysicalBase,
|
||||
Desc->Length
|
||||
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
|
||||
index 1a0fcbf8..daa4e6ae 100644
|
||||
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
|
||||
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
+#include <Library/TimerLib.h>
|
||||
#include <Library/UefiBootManagerLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
@@ -25,6 +26,7 @@
|
||||
#include <Protocol/EsrtManagement.h>
|
||||
#include <Protocol/GraphicsOutput.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
+#include <Protocol/PlatformSpecificResetHandler.h>
|
||||
#include <Guid/BootDiscoveryPolicy.h>
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/TtyTerm.h>
|
||||
@@ -527,6 +529,66 @@ SerialConPrint (
|
||||
}
|
||||
}
|
||||
|
||||
+/**
|
||||
+ Disconnect everything.
|
||||
+ Modified from the UEFI 2.3 spec (May 2009 version)
|
||||
+
|
||||
+**/
|
||||
+STATIC
|
||||
+VOID
|
||||
+DisconnectAll (
|
||||
+ VOID
|
||||
+ )
|
||||
+{
|
||||
+ EFI_STATUS Status;
|
||||
+ UINTN HandleCount;
|
||||
+ EFI_HANDLE *HandleBuffer;
|
||||
+ UINTN HandleIndex;
|
||||
+
|
||||
+ /*
|
||||
+ * Retrieve the list of all handles from the handle database
|
||||
+ */
|
||||
+ Status = gBS->LocateHandleBuffer (
|
||||
+ AllHandles,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ &HandleCount,
|
||||
+ &HandleBuffer
|
||||
+ );
|
||||
+ if (EFI_ERROR (Status)) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
|
||||
+ gBS->DisconnectController (HandleBuffer[HandleIndex], NULL, NULL);
|
||||
+ }
|
||||
+
|
||||
+ gBS->FreePool(HandleBuffer);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+STATIC
|
||||
+VOID
|
||||
+EFIAPI
|
||||
+OnResetNotify (
|
||||
+ IN EFI_RESET_TYPE ResetType,
|
||||
+ IN EFI_STATUS ResetStatus,
|
||||
+ IN UINTN DataSize,
|
||||
+ IN VOID *ResetData OPTIONAL
|
||||
+ )
|
||||
+{
|
||||
+ UINT32 Delay;
|
||||
+
|
||||
+ DisconnectAll ();
|
||||
+
|
||||
+ Delay = PcdGet32 (PcdPlatformResetDelay);
|
||||
+ if (Delay != 0) {
|
||||
+ DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n",
|
||||
+ Delay / 1000000, (Delay % 1000000) / 100000));
|
||||
+ MicroSecondDelay (Delay);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
//
|
||||
// BDS Platform Functions
|
||||
//
|
||||
@@ -549,6 +611,7 @@ PlatformBootManagerBeforeConsole (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
|
||||
+ EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL *ResetNotify;
|
||||
|
||||
if (GetBootModeHob () == BOOT_ON_FLASH_UPDATE) {
|
||||
DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n"));
|
||||
@@ -582,6 +645,21 @@ PlatformBootManagerBeforeConsole (
|
||||
EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, NULL);
|
||||
EfiBootManagerUpdateConsoleVariable (ErrOut, (EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, NULL);
|
||||
|
||||
+ Status = gBS->LocateProtocol (
|
||||
+ &gEdkiiPlatformSpecificResetHandlerProtocolGuid,
|
||||
+ NULL,
|
||||
+ (VOID **)&ResetNotify
|
||||
+ );
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ if (!EFI_ERROR (Status)) {
|
||||
+ Status = ResetNotify->RegisterResetNotify (
|
||||
+ ResetNotify,
|
||||
+ OnResetNotify
|
||||
+ );
|
||||
+ ASSERT_EFI_ERROR (Status);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
//
|
||||
// Signal EndOfDxe PI Event
|
||||
//
|
||||
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
index 5e55eff7..9e26828b 100644
|
||||
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
@@ -46,6 +46,7 @@
|
||||
MemoryAllocationLib
|
||||
PcdLib
|
||||
PrintLib
|
||||
+ TimerLib
|
||||
UefiBootManagerLib
|
||||
UefiBootServicesTableLib
|
||||
UefiLib
|
||||
@@ -63,6 +64,7 @@
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay
|
||||
gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
|
||||
|
||||
[Guids]
|
||||
@@ -78,6 +80,7 @@
|
||||
gEfiBootManagerPolicyConnectAllGuid
|
||||
|
||||
[Protocols]
|
||||
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid
|
||||
gEfiBootManagerPolicyProtocolGuid
|
||||
gEfiDevicePathProtocolGuid
|
||||
gEfiGraphicsOutputProtocolGuid
|
||||
@@ -86,3 +89,6 @@
|
||||
gEfiSimpleFileSystemProtocolGuid
|
||||
gEsrtManagementProtocolGuid
|
||||
gEfiUsb2HcProtocolGuid
|
||||
+
|
||||
+[Depex]
|
||||
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid
|
||||
diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c
|
||||
deleted file mode 100644
|
||||
index 2bcef8d4..00000000
|
||||
--- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c
|
||||
+++ /dev/null
|
||||
@@ -1,151 +0,0 @@
|
||||
-/** @file
|
||||
- *
|
||||
- * Support ResetSystem Runtime call using PSCI calls.
|
||||
- * Signals the gRaspberryPiEventResetGuid event group on reset.
|
||||
- *
|
||||
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
|
||||
- * Copyright (c) 2014, Linaro Ltd. All rights reserved.
|
||||
- * Copyright (c) 2013-2015, ARM Ltd. All rights reserved.
|
||||
- * Copyright (c) 2008-2009, Apple Inc. All rights reserved.
|
||||
- *
|
||||
- * SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
- *
|
||||
- **/
|
||||
-
|
||||
-#include <PiDxe.h>
|
||||
-
|
||||
-#include <Library/BaseLib.h>
|
||||
-#include <Library/DebugLib.h>
|
||||
-#include <Library/TimerLib.h>
|
||||
-#include <Library/EfiResetSystemLib.h>
|
||||
-#include <Library/ArmSmcLib.h>
|
||||
-#include <Library/UefiBootServicesTableLib.h>
|
||||
-#include <Library/UefiLib.h>
|
||||
-#include <Library/UefiRuntimeLib.h>
|
||||
-
|
||||
-#include <IndustryStandard/ArmStdSmc.h>
|
||||
-
|
||||
-
|
||||
-/**
|
||||
- Disconnect everything.
|
||||
- Modified from the UEFI 2.3 spec (May 2009 version)
|
||||
-
|
||||
-**/
|
||||
-STATIC
|
||||
-VOID
|
||||
-DisconnectAll (
|
||||
- VOID
|
||||
- )
|
||||
-{
|
||||
- EFI_STATUS Status;
|
||||
- UINTN HandleCount;
|
||||
- EFI_HANDLE *HandleBuffer;
|
||||
- UINTN HandleIndex;
|
||||
-
|
||||
- /*
|
||||
- * Retrieve the list of all handles from the handle database
|
||||
- */
|
||||
- Status = gBS->LocateHandleBuffer (
|
||||
- AllHandles,
|
||||
- NULL,
|
||||
- NULL,
|
||||
- &HandleCount,
|
||||
- &HandleBuffer
|
||||
- );
|
||||
- if (EFI_ERROR (Status)) {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
|
||||
- gBS->DisconnectController (HandleBuffer[HandleIndex], NULL, NULL);
|
||||
- }
|
||||
-
|
||||
- gBS->FreePool(HandleBuffer);
|
||||
-}
|
||||
-
|
||||
-
|
||||
-/**
|
||||
- Resets the entire platform.
|
||||
-
|
||||
- @param ResetType The type of reset to perform.
|
||||
- @param ResetStatus The status code for the reset.
|
||||
- @param DataSize The size, in bytes, of WatchdogData.
|
||||
- @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
|
||||
- EfiResetShutdown the data buffer starts with a Null-terminated
|
||||
- Unicode string, optionally followed by additional binary data.
|
||||
-
|
||||
-**/
|
||||
-EFI_STATUS
|
||||
-EFIAPI
|
||||
-LibResetSystem (
|
||||
- IN EFI_RESET_TYPE ResetType,
|
||||
- IN EFI_STATUS ResetStatus,
|
||||
- IN UINTN DataSize,
|
||||
- IN CHAR16 *ResetData OPTIONAL
|
||||
- )
|
||||
-{
|
||||
- ARM_SMC_ARGS ArmSmcArgs;
|
||||
- UINT32 Delay;
|
||||
-
|
||||
- if (!EfiAtRuntime ()) {
|
||||
- /*
|
||||
- * Only if still in UEFI.
|
||||
- */
|
||||
- EfiEventGroupSignal (&gRaspberryPiEventResetGuid);
|
||||
-
|
||||
- DisconnectAll ();
|
||||
-
|
||||
- Delay = PcdGet32 (PcdPlatformResetDelay);
|
||||
- if (Delay != 0) {
|
||||
- DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n",
|
||||
- Delay / 1000000, (Delay % 1000000) / 100000));
|
||||
- MicroSecondDelay (Delay);
|
||||
- }
|
||||
- }
|
||||
- DEBUG ((DEBUG_INFO, "Platform %a.\n",
|
||||
- (ResetType == EfiResetShutdown) ? "shutdown" : "reset"));
|
||||
-
|
||||
- switch (ResetType) {
|
||||
- case EfiResetPlatformSpecific:
|
||||
- // Map the platform specific reset as reboot
|
||||
- case EfiResetWarm:
|
||||
- // Map a warm reset into a cold reset
|
||||
- case EfiResetCold:
|
||||
- // Send a PSCI 0.2 SYSTEM_RESET command
|
||||
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
||||
- break;
|
||||
- case EfiResetShutdown:
|
||||
- // Send a PSCI 0.2 SYSTEM_OFF command
|
||||
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
||||
- break;
|
||||
- default:
|
||||
- ASSERT (FALSE);
|
||||
- return EFI_UNSUPPORTED;
|
||||
- }
|
||||
-
|
||||
- ArmCallSmc (&ArmSmcArgs);
|
||||
-
|
||||
- // We should never be here
|
||||
- DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));
|
||||
- CpuDeadLoop ();
|
||||
- return EFI_UNSUPPORTED;
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
- Initialize any infrastructure required for LibResetSystem () to function.
|
||||
-
|
||||
- @param ImageHandle The firmware allocated handle for the EFI image.
|
||||
- @param SystemTable A pointer to the EFI System Table.
|
||||
-
|
||||
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||
-
|
||||
-**/
|
||||
-EFI_STATUS
|
||||
-EFIAPI
|
||||
-LibInitializeResetSystem (
|
||||
- IN EFI_HANDLE ImageHandle,
|
||||
- IN EFI_SYSTEM_TABLE *SystemTable
|
||||
- )
|
||||
-{
|
||||
- return EFI_SUCCESS;
|
||||
-}
|
||||
diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.inf b/Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
|
||||
deleted file mode 100644
|
||||
index 9bdb94a5..00000000
|
||||
--- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
|
||||
+++ /dev/null
|
||||
@@ -1,45 +0,0 @@
|
||||
-#/** @file
|
||||
-#
|
||||
-# Reset System lib using PSCI hypervisor or secure monitor calls.
|
||||
-# Signals the gRaspberryPiEventResetGuid event group on reset.
|
||||
-#
|
||||
-# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
|
||||
-# Copyright (c) 2014, Linaro Ltd. All rights reserved.
|
||||
-# Copyright (c) 2014, ARM Ltd. All rights reserved.
|
||||
-# Copyright (c) 2008, Apple Inc. All rights reserved.
|
||||
-#
|
||||
-# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
-#
|
||||
-#**/
|
||||
-
|
||||
-[Defines]
|
||||
- INF_VERSION = 0x0001001A
|
||||
- BASE_NAME = ResetLib
|
||||
- FILE_GUID = B9F59B69-A105-41C7-8F5A-2C60DD7FD7AB
|
||||
- MODULE_TYPE = BASE
|
||||
- VERSION_STRING = 1.0
|
||||
- LIBRARY_CLASS = EfiResetSystemLib
|
||||
-
|
||||
-[Sources]
|
||||
- ResetLib.c
|
||||
-
|
||||
-[Packages]
|
||||
- ArmPkg/ArmPkg.dec
|
||||
- MdePkg/MdePkg.dec
|
||||
- EmbeddedPkg/EmbeddedPkg.dec
|
||||
- Platform/RaspberryPi/RaspberryPi.dec
|
||||
-
|
||||
-[LibraryClasses]
|
||||
- DebugLib
|
||||
- BaseLib
|
||||
- ArmSmcLib
|
||||
- PcdLib
|
||||
- TimerLib
|
||||
- UefiLib
|
||||
- UefiRuntimeLib
|
||||
-
|
||||
-[Guids]
|
||||
- gRaspberryPiEventResetGuid
|
||||
-
|
||||
-[Pcd]
|
||||
- gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay ## CONSUMES
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Library/PlatformLib/AArch64/RaspberryPiHelper.S b/Platform/RaspberryPi/RPi5/Library/PlatformLib/AArch64/RaspberryPiHelper.S
|
||||
index 5972fcdf..21457c89 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Library/PlatformLib/AArch64/RaspberryPiHelper.S
|
||||
+++ b/Platform/RaspberryPi/RPi5/Library/PlatformLib/AArch64/RaspberryPiHelper.S
|
||||
@@ -86,31 +86,4 @@ ASM_FUNC (ArmPlatformPeiBootAction)
|
||||
.long 0 // end tag
|
||||
.set .Lmeminfo_size, . - .Lmeminfo_buffer
|
||||
|
||||
-//UINTN
|
||||
-//ArmPlatformGetPrimaryCoreMpId (
|
||||
-// VOID
|
||||
-// );
|
||||
-ASM_FUNC (ArmPlatformGetPrimaryCoreMpId)
|
||||
- MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))
|
||||
- ret
|
||||
-
|
||||
-//UINTN
|
||||
-//ArmPlatformIsPrimaryCore (
|
||||
-// IN UINTN MpId
|
||||
-// );
|
||||
-ASM_FUNC (ArmPlatformIsPrimaryCore)
|
||||
- mov x0, #1
|
||||
- ret
|
||||
-
|
||||
-//UINTN
|
||||
-//ArmPlatformGetCorePosition (
|
||||
-// IN UINTN MpId
|
||||
-// );
|
||||
-// With this function: CorePos = (ClusterId * 4) + CoreId
|
||||
-ASM_FUNC (ArmPlatformGetCorePosition)
|
||||
- and x1, x0, #ARM_CORE_MASK
|
||||
- and x0, x0, #ARM_CLUSTER_MASK
|
||||
- add x0, x1, x0, LSR #6
|
||||
- ret
|
||||
-
|
||||
ASM_FUNCTION_REMOVE_IF_UNREFERENCED
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 3aab6ea8..0f3b669c 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -138,9 +138,7 @@
|
||||
ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf
|
||||
DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
|
||||
TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
|
||||
- ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
|
||||
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||
- ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
|
||||
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
|
||||
|
||||
# Dual serial port library
|
||||
@@ -212,7 +210,6 @@
|
||||
MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
|
||||
PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
|
||||
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
|
||||
- LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
|
||||
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
|
||||
HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
|
||||
PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
|
||||
@@ -251,8 +248,8 @@
|
||||
DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
|
||||
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
||||
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
|
||||
- EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
|
||||
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||
+ ArmMonitorLib|ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf
|
||||
+ ResetSystemLib|ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf
|
||||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
|
||||
|
||||
!if $(SECURE_BOOT_ENABLE) == TRUE
|
||||
@@ -523,9 +520,11 @@
|
||||
#
|
||||
# PEI Phase modules
|
||||
#
|
||||
- ArmPlatformPkg/PrePi/PeiUniCore.inf
|
||||
-
|
||||
- #
|
||||
+ ArmPlatformPkg/PeilessSec/PeilessSec.inf {
|
||||
+ <LibraryClasses>
|
||||
+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
|
||||
+ }
|
||||
+#
|
||||
# DXE
|
||||
#
|
||||
MdeModulePkg/Core/Dxe/DxeMain.inf {
|
||||
@@ -543,9 +542,13 @@
|
||||
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
|
||||
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
|
||||
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
|
||||
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
|
||||
+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf {
|
||||
+ <LibraryClasses>
|
||||
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
|
||||
+ }
|
||||
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
|
||||
<LibraryClasses>
|
||||
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
|
||||
NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
|
||||
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
|
||||
}
|
||||
@@ -562,7 +565,7 @@
|
||||
!endif
|
||||
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
|
||||
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
|
||||
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
|
||||
+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
|
||||
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
|
||||
<LibraryClasses>
|
||||
RealTimeClockLib|Platform/RaspberryPi/Library/RpiRtcLib/RpiRtcLib.inf
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 8d79e453..125d5fee 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -195,7 +195,7 @@ READ_LOCK_STATUS = TRUE
|
||||
INF SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.inf
|
||||
!endif
|
||||
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
|
||||
- INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
|
||||
+ INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
|
||||
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
|
||||
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
|
||||
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
|
||||
@@ -351,7 +351,7 @@ READ_STATUS = TRUE
|
||||
READ_LOCK_CAP = TRUE
|
||||
READ_LOCK_STATUS = TRUE
|
||||
|
||||
- INF ArmPlatformPkg/PrePi/PeiUniCore.inf
|
||||
+ INF ArmPlatformPkg/PeilessSec/PeilessSec.inf
|
||||
FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
|
||||
SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {
|
||||
SECTION FV_IMAGE = FVMAIN
|
||||
diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
|
||||
index 0c636cbf..5c050f89 100644
|
||||
--- a/Platform/RaspberryPi/RaspberryPi.dec
|
||||
+++ b/Platform/RaspberryPi/RaspberryPi.dec
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
[Guids]
|
||||
gRaspberryPiTokenSpaceGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
|
||||
- gRaspberryPiEventResetGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB4, 0xB4, 0xE4, 0xD4, 0xB4}}
|
||||
gConfigDxeFormSetGuid = {0xCD7CC258, 0x31DB, 0x22E6, {0x9F, 0x22, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
|
||||
gMemoryAttributeManagerFormSetGuid = { 0xefab3427, 0x4793, 0x4e9e, { 0xaa, 0x29, 0x88, 0x0c, 0x9a, 0x77, 0x5b, 0x5f } }
|
||||
|
||||
--
|
||||
2.51.2
|
||||
|
||||
9472
packages/edk2/patches/platforms/0023-Nov-29-update.patch
Normal file
9472
packages/edk2/patches/platforms/0023-Nov-29-update.patch
Normal file
File diff suppressed because it is too large
Load Diff
114
packages/edk2/patches/platforms/0024-Through-Feb-21.patch
Normal file
114
packages/edk2/patches/platforms/0024-Through-Feb-21.patch
Normal file
@@ -0,0 +1,114 @@
|
||||
From 6440aeda3459edd32adf5015a7fcfc7989c7bfbd Mon Sep 17 00:00:00 2001
|
||||
From: mattp <svidasultaresurge@gmail.com>
|
||||
Date: Tue, 8 Jul 2025 16:50:27 -0400
|
||||
Subject: [PATCH 24/29] Through Feb 21
|
||||
|
||||
---
|
||||
.../RPi5/Library/PlatformLib/PlatformLib.inf | 4 +---
|
||||
.../RPi5/Library/PlatformLib/RaspberryPiMem.c | 13 +++----------
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 8 +-------
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 2 +-
|
||||
4 files changed, 6 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf b/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf
|
||||
index 765a5807..24ef8368 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf
|
||||
+++ b/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf
|
||||
@@ -56,9 +56,7 @@
|
||||
gArmTokenSpaceGuid.PcdSystemMemoryBase
|
||||
gArmTokenSpaceGuid.PcdSystemMemorySize
|
||||
gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogSize
|
||||
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
|
||||
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
|
||||
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdNvStorageVariableBase
|
||||
gRaspberryPiTokenSpaceGuid.PcdFwMailboxBaseAddress
|
||||
|
||||
[Ppis]
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Library/PlatformLib/RaspberryPiMem.c b/Platform/RaspberryPi/RPi5/Library/PlatformLib/RaspberryPiMem.c
|
||||
index 98575625..c0632fb2 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Library/PlatformLib/RaspberryPiMem.c
|
||||
+++ b/Platform/RaspberryPi/RPi5/Library/PlatformLib/RaspberryPiMem.c
|
||||
@@ -27,14 +27,7 @@ extern UINT64 mSystemMemoryEnd;
|
||||
STATIC BOOLEAN VirtualMemoryInfoInitialized = FALSE;
|
||||
STATIC RPI_MEMORY_REGION_INFO VirtualMemoryInfo[MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS];
|
||||
|
||||
-#define VariablesSize (FixedPcdGet32(PcdFlashNvStorageVariableSize) + \
|
||||
- FixedPcdGet32(PcdFlashNvStorageFtwWorkingSize) + \
|
||||
- FixedPcdGet32(PcdFlashNvStorageFtwSpareSize) + \
|
||||
- FixedPcdGet32(PcdNvStorageEventLogSize))
|
||||
-
|
||||
-#define VariablesBase (FixedPcdGet64(PcdFdBaseAddress) + \
|
||||
- FixedPcdGet32(PcdFdSize) - \
|
||||
- VariablesSize)
|
||||
+#define VariablesBase (FixedPcdGet32(PcdNvStorageVariableBase))
|
||||
|
||||
/**
|
||||
Return the Virtual Memory Map of your platform
|
||||
@@ -93,7 +86,7 @@ ArmPlatformGetVirtualMemoryMap (
|
||||
// Firmware Volume
|
||||
VirtualMemoryTable[Index].PhysicalBase = FixedPcdGet64 (PcdFdBaseAddress);
|
||||
VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase;
|
||||
- VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdFdSize) - VariablesSize;
|
||||
+ VirtualMemoryTable[Index].Length = VariablesBase - VirtualMemoryTable[Index].PhysicalBase;
|
||||
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
||||
VirtualMemoryInfo[Index].Type = RPI_MEM_RESERVED_REGION;
|
||||
VirtualMemoryInfo[Index++].Name = L"FD";
|
||||
@@ -101,7 +94,7 @@ ArmPlatformGetVirtualMemoryMap (
|
||||
// Variable Volume
|
||||
VirtualMemoryTable[Index].PhysicalBase = VariablesBase;
|
||||
VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase;
|
||||
- VirtualMemoryTable[Index].Length = VariablesSize;
|
||||
+ VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdFdtBaseAddress) - VariablesBase;
|
||||
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
||||
VirtualMemoryInfo[Index].Type = RPI_MEM_RUNTIME_REGION;
|
||||
VirtualMemoryInfo[Index++].Name = L"FD Variables";
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 8ab4f15a..fae154bc 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -124,9 +124,6 @@
|
||||
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
|
||||
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
|
||||
CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
|
||||
- ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
|
||||
- ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
|
||||
- ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf
|
||||
DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
|
||||
TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
|
||||
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||
@@ -271,9 +268,6 @@
|
||||
################################################################################
|
||||
|
||||
[PcdsFeatureFlag.common]
|
||||
- # Use the Vector Table location in CpuDxe. We will not copy the Vector Table at PcdCpuVectorBaseAddress
|
||||
- gArmTokenSpaceGuid.PcdRelocateVectorTable|FALSE
|
||||
-
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|TRUE
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
|
||||
|
||||
@@ -573,7 +567,7 @@
|
||||
|
||||
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
|
||||
|
||||
- ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
|
||||
+ ArmPkg/Drivers/ArmGicDxe/ArmGicV2Dxe.inf
|
||||
Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 125d5fee..23c37e26 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -212,7 +212,7 @@ READ_LOCK_STATUS = TRUE
|
||||
INF Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
|
||||
INF EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf
|
||||
|
||||
- INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
|
||||
+ INF ArmPkg/Drivers/ArmGicDxe/ArmGicV2Dxe.inf
|
||||
INF Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
INF Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
INF Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
--
|
||||
2.51.2
|
||||
|
||||
88
packages/edk2/patches/platforms/0025-Late-May.patch
Normal file
88
packages/edk2/patches/platforms/0025-Late-May.patch
Normal file
@@ -0,0 +1,88 @@
|
||||
From 2bc42373ed7b3a36397274db719dd682338215aa Mon Sep 17 00:00:00 2001
|
||||
From: mattp <svidasultaresurge@gmail.com>
|
||||
Date: Tue, 8 Jul 2025 19:02:01 -0400
|
||||
Subject: [PATCH 25/29] Late May
|
||||
|
||||
---
|
||||
.../RPi5/Library/PlatformLib/PlatformLib.inf | 1 -
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 11 +++++++----
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 1 +
|
||||
3 files changed, 8 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf b/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf
|
||||
index 24ef8368..42fa84bf 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf
|
||||
+++ b/Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
[LibraryClasses]
|
||||
ArmLib
|
||||
- FdtLib
|
||||
IoLib
|
||||
MemoryAllocationLib
|
||||
PcdLib
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index fae154bc..e7eed390 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -126,7 +126,7 @@
|
||||
CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
|
||||
DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
|
||||
TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
|
||||
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||
+ ArmSmcLib|MdePkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
|
||||
|
||||
# Dual serial port library
|
||||
@@ -155,7 +155,7 @@
|
||||
DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
|
||||
|
||||
# Flattened Device Tree (FDT) access library
|
||||
- FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
|
||||
+ FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
|
||||
|
||||
# USB Libraries
|
||||
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
|
||||
@@ -385,7 +385,6 @@
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
gArmPlatformTokenSpaceGuid.PcdCoreCount|4
|
||||
- gArmTokenSpaceGuid.PcdVFPEnabled|1
|
||||
|
||||
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
|
||||
@@ -548,6 +547,7 @@
|
||||
!else
|
||||
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
|
||||
!endif
|
||||
+ SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf
|
||||
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
|
||||
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
|
||||
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
|
||||
@@ -570,7 +570,10 @@
|
||||
ArmPkg/Drivers/ArmGicDxe/ArmGicV2Dxe.inf
|
||||
Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
+ Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf {
|
||||
+ <LibraryClasses>
|
||||
+ FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf # Map to deprecated library for this module only
|
||||
+ }
|
||||
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
|
||||
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
|
||||
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 23c37e26..917f5aab 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -194,6 +194,7 @@ READ_LOCK_STATUS = TRUE
|
||||
INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
|
||||
INF SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.inf
|
||||
!endif
|
||||
+ INF SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf
|
||||
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
|
||||
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
|
||||
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
From 902d8c57dd28b13d10044e4a6f67b406ebb5e45b Mon Sep 17 00:00:00 2001
|
||||
From: mattp <svidasultaresurge@gmail.com>
|
||||
Date: Thu, 17 Jul 2025 19:18:53 -0400
|
||||
Subject: [PATCH 26/29] Allocate more space for UEFI image
|
||||
|
||||
---
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 12 ++++++++----
|
||||
Platform/RaspberryPi/RPi5/RPi5.fdf | 20 ++++++++++++--------
|
||||
2 files changed, 20 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index e7eed390..8edf0458 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -286,6 +286,10 @@
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
|
||||
+ #
|
||||
+ # Follows right after the FD image. (bump the size again)
|
||||
+ #
|
||||
+ gRaspberryPiTokenSpaceGuid.PcdFdtBaseAddress|0x003e0000
|
||||
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|$(DEBUG_PROPERTY_MASK)
|
||||
|
||||
@@ -394,11 +398,11 @@
|
||||
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000
|
||||
#
|
||||
# 0x00000000 - 0x001F0000 FD (PcdFdBaseAddress, PcdFdSize)
|
||||
- # 0x001F0000 - 0x00210000 DTB (PcdFdtBaseAddress, PcdFdtSize)
|
||||
- # 0x00210000 - ... RAM (PcdSystemMemoryBase, PcdSystemMemorySize)
|
||||
+ # 0x003E0000 - 0x00400000 DTB (PcdFdtBaseAddress, PcdFdtSize)
|
||||
+ # 0x00400000 - ... RAM (PcdSystemMemoryBase, PcdSystemMemorySize)
|
||||
#
|
||||
- gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00210000
|
||||
- gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fdf0000
|
||||
+ gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00400000
|
||||
+ gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fc00000
|
||||
|
||||
gRaspberryPiTokenSpaceGuid.PcdFdtSize|0x20000
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.fdf b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
index 917f5aab..19b169aa 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.fdf
|
||||
@@ -26,11 +26,11 @@
|
||||
|
||||
[FD.RPI_EFI]
|
||||
BaseAddress = 0x00000000|gArmTokenSpaceGuid.PcdFdBaseAddress
|
||||
-Size = 0x001f0000|gArmTokenSpaceGuid.PcdFdSize
|
||||
+Size = 0x003e0000|gArmTokenSpaceGuid.PcdFdSize
|
||||
ErasePolarity = 1
|
||||
|
||||
BlockSize = 0x00001000|gRaspberryPiTokenSpaceGuid.PcdFirmwareBlockSize
|
||||
-NumBlocks = 0x1f0
|
||||
+NumBlocks = 0x3e0
|
||||
|
||||
################################################################################
|
||||
#
|
||||
@@ -57,7 +57,7 @@ FILE = $(TFA_BUILD_BL31)
|
||||
#
|
||||
# UEFI image
|
||||
#
|
||||
-0x00020000|0x001b0000
|
||||
+0x00020000|0x00390000
|
||||
gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
|
||||
FV = FVMAIN_COMPACT
|
||||
|
||||
@@ -71,7 +71,7 @@ FV = FVMAIN_COMPACT
|
||||
#
|
||||
|
||||
# NV_VARIABLE_STORE
|
||||
-0x001d0000|0x0000e000
|
||||
+0x003b0000|0x0000e000
|
||||
gRaspberryPiTokenSpaceGuid.PcdNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
|
||||
|
||||
DATA = {
|
||||
@@ -114,11 +114,11 @@ DATA = {
|
||||
}
|
||||
|
||||
# NV_EVENT_LOG
|
||||
-0x001de000|0x00001000
|
||||
+0x003be000|0x00001000
|
||||
gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogBase|gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogSize
|
||||
|
||||
# NV_FTW_WORKING header
|
||||
-0x001df000|0x00001000
|
||||
+0x003bf000|0x00001000
|
||||
gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
|
||||
|
||||
DATA = {
|
||||
@@ -133,14 +133,18 @@ DATA = {
|
||||
}
|
||||
|
||||
# NV_FTW_WORKING data
|
||||
-0x001e0000|0x00010000
|
||||
+0x003c0000|0x00010000
|
||||
gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
|
||||
|
||||
+# reserve some future RAM for the ACPI PCC channel structures, immediately before the DTB
|
||||
+# 0x003d0000|0x00010000
|
||||
+# gRaspberryPiTokenSpaceGuid.PcdPccBaseAddress|gRaspberryPiTokenSpaceGuid.PcdPccSize
|
||||
+
|
||||
#
|
||||
# This is just for documentation purposes! The DTB reserved space is not part of the FD,
|
||||
# but this is exactly where it is expected to be.
|
||||
#
|
||||
-# 0x001f0000|0x10000
|
||||
+# 0x003e0000|0x20000
|
||||
# gRaspberryPiTokenSpaceGuid.PcdFdtBaseAddress|gRaspberryPiTokenSpaceGuid.PcdFdtSize
|
||||
#
|
||||
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
From 364f14e0172df42ccee8fd2416c2e997a6bb9527 Mon Sep 17 00:00:00 2001
|
||||
From: mattp <svidasultaresurge@gmail.com>
|
||||
Date: Fri, 18 Jul 2025 08:39:17 -0400
|
||||
Subject: [PATCH 27/29] Update ArmMmuLib library path
|
||||
|
||||
---
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 8edf0458..1cd72681 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -362,7 +362,7 @@
|
||||
|
||||
[LibraryClasses.common]
|
||||
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
|
||||
- ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
|
||||
+ ArmMmuLib|UefiCpuPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
|
||||
ArmPlatformLib|Platform/RaspberryPi/RPi5/Library/PlatformLib/PlatformLib.inf
|
||||
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
|
||||
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,510 @@
|
||||
From 2db245b3ae93b0dae3d8f4898f7f444201eac4b4 Mon Sep 17 00:00:00 2001
|
||||
From: mattp <svidasultaresurge@gmail.com>
|
||||
Date: Sat, 19 Jul 2025 08:40:50 -0400
|
||||
Subject: [PATCH 28/29] Fix Fdt and remove Uga
|
||||
|
||||
---
|
||||
Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c | 105 +++++++++---------
|
||||
.../RaspberryPi/Drivers/FdtDxe/FdtDxe.inf | 1 +
|
||||
.../Library/BoardInfoLib/BoardInfoLib.c | 14 +--
|
||||
.../Library/FdtPlatformLib/FdtPlatformLib.c | 6 +-
|
||||
.../MemoryInitPeiLib/MemoryInitPeiLib.inf | 1 +
|
||||
.../PlatformBootManagerLib.inf | 1 -
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 8 +-
|
||||
7 files changed, 66 insertions(+), 70 deletions(-)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
|
||||
index d0a448df..7b7b5676 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
|
||||
+++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
+#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/BoardInfoLib.h>
|
||||
#include <Library/BoardRevisionHelperLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
@@ -17,7 +18,7 @@
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
-#include <libfdt.h>
|
||||
+#include <Library/FdtLib.h>
|
||||
#include <Protocol/RpiFirmware.h>
|
||||
#include <Guid/Fdt.h>
|
||||
#include <ConfigVars.h>
|
||||
@@ -45,13 +46,13 @@ FixEthernetAliases (
|
||||
//
|
||||
// Look up the 'ethernet[0]' aliases
|
||||
//
|
||||
- Aliases = fdt_path_offset (mFdtImage, "/aliases");
|
||||
+ Aliases = FdtPathOffset (mFdtImage, "/aliases");
|
||||
if (Aliases < 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate '/aliases'\n", __func__));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
- Ethernet = fdt_getprop (mFdtImage, Aliases, "ethernet", NULL);
|
||||
- Ethernet0 = fdt_getprop (mFdtImage, Aliases, "ethernet0", NULL);
|
||||
+ Ethernet = FdtGetProp (mFdtImage, Aliases, "ethernet", NULL);
|
||||
+ Ethernet0 = FdtGetProp (mFdtImage, Aliases, "ethernet0", NULL);
|
||||
Alias = Ethernet ? Ethernet : Ethernet0;
|
||||
if (!Alias) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate 'ethernet[0]' alias\n", __func__));
|
||||
@@ -59,7 +60,7 @@ FixEthernetAliases (
|
||||
}
|
||||
|
||||
//
|
||||
- // Create copy for fdt_setprop
|
||||
+ // Create copy for FdtSetProp
|
||||
//
|
||||
CopySize = AsciiStrSize (Alias);
|
||||
Copy = AllocateCopyPool (CopySize, Alias);
|
||||
@@ -73,7 +74,7 @@ FixEthernetAliases (
|
||||
//
|
||||
Status = EFI_SUCCESS;
|
||||
if (!Ethernet) {
|
||||
- Retval = fdt_setprop (mFdtImage, Aliases, "ethernet", Copy, CopySize);
|
||||
+ Retval = FdtSetProp (mFdtImage, Aliases, "ethernet", Copy, CopySize);
|
||||
if (Retval != 0) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to create 'ethernet' alias (%d)\n",
|
||||
@@ -82,7 +83,7 @@ FixEthernetAliases (
|
||||
DEBUG ((DEBUG_INFO, "%a: created 'ethernet' alias '%a'\n", __func__, Copy));
|
||||
}
|
||||
if (!Ethernet0) {
|
||||
- Retval = fdt_setprop (mFdtImage, Aliases, "ethernet0", Copy, CopySize);
|
||||
+ Retval = FdtSetProp (mFdtImage, Aliases, "ethernet0", Copy, CopySize);
|
||||
if (Retval != 0) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to create 'ethernet0' alias (%d)\n",
|
||||
@@ -109,7 +110,7 @@ UpdateMacAddress (
|
||||
//
|
||||
// Locate the node that the 'ethernet' alias refers to
|
||||
//
|
||||
- Node = fdt_path_offset (mFdtImage, "ethernet");
|
||||
+ Node = FdtPathOffset (mFdtImage, "ethernet");
|
||||
if (Node < 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate 'ethernet' alias\n", __func__));
|
||||
return EFI_NOT_FOUND;
|
||||
@@ -124,7 +125,7 @@ UpdateMacAddress (
|
||||
return Status;
|
||||
}
|
||||
|
||||
- Retval = fdt_setprop (mFdtImage, Node, "mac-address", MacAddress,
|
||||
+ Retval = FdtSetProp (mFdtImage, Node, "mac-address", MacAddress,
|
||||
sizeof MacAddress);
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to create 'mac-address' property (%d)\n",
|
||||
@@ -157,28 +158,28 @@ AddUsbCompatibleProperty (
|
||||
INTN Retval;
|
||||
|
||||
// Locate the node that the 'usb' alias refers to
|
||||
- Node = fdt_path_offset (mFdtImage, "usb");
|
||||
+ Node = FdtPathOffset (mFdtImage, "usb");
|
||||
if (Node < 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate 'usb' alias\n", __func__));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Get the property list. This is a list of NUL terminated strings.
|
||||
- List = fdt_getprop (mFdtImage, Node, "compatible", &ListSize);
|
||||
+ List = FdtGetProp (mFdtImage, Node, "compatible", &ListSize);
|
||||
if (List == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate properties\n", __func__));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Check if the compatible value we plan to add is already present
|
||||
- if (fdt_stringlist_contains (List, ListSize, NewProp)) {
|
||||
+ if (FdtStringListContains (List, ListSize, NewProp)) {
|
||||
DEBUG ((DEBUG_INFO, "%a: property '%a' is already set.\n",
|
||||
__func__, NewProp));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
// Make sure the compatible device is what we expect
|
||||
- if (!fdt_stringlist_contains (List, ListSize, Prop)) {
|
||||
+ if (!FdtStringListContains (List, ListSize, Prop)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: property '%a' is missing!\n",
|
||||
__func__, Prop));
|
||||
return EFI_NOT_FOUND;
|
||||
@@ -196,7 +197,7 @@ AddUsbCompatibleProperty (
|
||||
CopyMem (NewList, List, ListSize);
|
||||
CopyMem (&NewList[ListSize], NewProp, sizeof (NewProp));
|
||||
|
||||
- Retval = fdt_setprop (mFdtImage, Node, "compatible", NewList,
|
||||
+ Retval = FdtSetProp (mFdtImage, Node, "compatible", NewList,
|
||||
ListSize + sizeof (NewProp));
|
||||
FreePool (NewList);
|
||||
if (Retval != 0) {
|
||||
@@ -217,7 +218,7 @@ CleanMemoryNodes (
|
||||
INTN Node;
|
||||
INT32 Retval;
|
||||
|
||||
- Node = fdt_path_offset (mFdtImage, "/memory");
|
||||
+ Node = FdtPathOffset (mFdtImage, "/memory");
|
||||
if (Node < 0) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -227,7 +228,7 @@ CleanMemoryNodes (
|
||||
* OS go crazy and ignore the UEFI map.
|
||||
*/
|
||||
DEBUG ((DEBUG_INFO, "Removing bogus /memory\n"));
|
||||
- Retval = fdt_del_node (mFdtImage, Node);
|
||||
+ Retval = FdtDelNode (mFdtImage, Node);
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to remove /memory\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
@@ -246,15 +247,15 @@ SanitizePSCI (
|
||||
INTN Root;
|
||||
INT32 Retval;
|
||||
|
||||
- Root = fdt_path_offset (mFdtImage, "/");
|
||||
+ Root = FdtPathOffset (mFdtImage, "/");
|
||||
ASSERT (Root >= 0);
|
||||
if (Root < 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Node = fdt_path_offset (mFdtImage, "/psci");
|
||||
+ Node = FdtPathOffset (mFdtImage, "/psci");
|
||||
if (Node < 0) {
|
||||
- Node = fdt_add_subnode (mFdtImage, Root, "psci");
|
||||
+ Node = FdtAddSubnode (mFdtImage, Root, "psci");
|
||||
}
|
||||
|
||||
ASSERT (Node >= 0);
|
||||
@@ -263,33 +264,33 @@ SanitizePSCI (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Retval = fdt_setprop_string (mFdtImage, Node, "compatible", "arm,psci-1.0");
|
||||
+ Retval = FdtSetPropString (mFdtImage, Node, "compatible", "arm,psci-1.0");
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Couldn't set /psci compatible property\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Retval = fdt_setprop_string (mFdtImage, Node, "method", "smc");
|
||||
+ Retval = FdtSetPropString (mFdtImage, Node, "method", "smc");
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Couldn't set /psci method property\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Root = fdt_path_offset (mFdtImage, "/cpus");
|
||||
+ Root = FdtPathOffset (mFdtImage, "/cpus");
|
||||
if (Root < 0) {
|
||||
DEBUG ((DEBUG_ERROR, "No CPUs to update with PSCI enable-method?\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Node = fdt_first_subnode (mFdtImage, Root);
|
||||
+ Node = FdtFirstSubnode (mFdtImage, Root);
|
||||
while (Node >= 0) {
|
||||
- if (fdt_setprop_string (mFdtImage, Node, "enable-method", "psci") != 0) {
|
||||
+ if (FdtSetPropString (mFdtImage, Node, "enable-method", "psci") != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to update enable-method for a CPU\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- fdt_delprop (mFdtImage, Node, "cpu-release-addr");
|
||||
- Node = fdt_next_subnode (mFdtImage, Node);
|
||||
+ FdtDelProp (mFdtImage, Node, "cpu-release-addr");
|
||||
+ Node = FdtNextSubnode (mFdtImage, Node);
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -307,7 +308,7 @@ CleanSimpleFramebuffer (
|
||||
* Should look for nodes by kind and remove aliases
|
||||
* by matching against device.
|
||||
*/
|
||||
- Node = fdt_path_offset (mFdtImage, "display0");
|
||||
+ Node = FdtPathOffset (mFdtImage, "display0");
|
||||
if (Node < 0) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -317,19 +318,19 @@ CleanSimpleFramebuffer (
|
||||
* doesn't reflect the framebuffer built by UEFI.
|
||||
*/
|
||||
DEBUG ((DEBUG_INFO, "Removing bogus display0\n"));
|
||||
- Retval = fdt_del_node (mFdtImage, Node);
|
||||
+ Retval = FdtDelNode (mFdtImage, Node);
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to remove display0\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Node = fdt_path_offset (mFdtImage, "/aliases");
|
||||
+ Node = FdtPathOffset (mFdtImage, "/aliases");
|
||||
if (Node < 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Couldn't find /aliases to remove display0\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Retval = fdt_delprop (mFdtImage, Node, "display0");
|
||||
+ Retval = FdtDelProp (mFdtImage, Node, "display0");
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to remove display0 alias\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
@@ -349,20 +350,20 @@ SyncPcie (
|
||||
INTN Retval;
|
||||
UINT32 DmaRanges[7];
|
||||
|
||||
- Node = fdt_path_offset (mFdtImage, "pcie0");
|
||||
+ Node = FdtPathOffset (mFdtImage, "pcie0");
|
||||
if (Node < 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate 'pcie0' alias\n", __func__));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
// non translated 32-bit DMA window with a limit of 0xc0000000
|
||||
- DmaRanges[0] = cpu_to_fdt32 (0x02000000);
|
||||
- DmaRanges[1] = cpu_to_fdt32 (0x00000000);
|
||||
- DmaRanges[2] = cpu_to_fdt32 (0x00000000);
|
||||
- DmaRanges[3] = cpu_to_fdt32 (0x00000000);
|
||||
- DmaRanges[4] = cpu_to_fdt32 (0x00000000);
|
||||
- DmaRanges[5] = cpu_to_fdt32 (0x00000000);
|
||||
- DmaRanges[6] = cpu_to_fdt32 (0xc0000000);
|
||||
+ DmaRanges[0] = CpuToFdt32 (0x02000000);
|
||||
+ DmaRanges[1] = CpuToFdt32 (0x00000000);
|
||||
+ DmaRanges[2] = CpuToFdt32 (0x00000000);
|
||||
+ DmaRanges[3] = CpuToFdt32 (0x00000000);
|
||||
+ DmaRanges[4] = CpuToFdt32 (0x00000000);
|
||||
+ DmaRanges[5] = CpuToFdt32 (0x00000000);
|
||||
+ DmaRanges[6] = CpuToFdt32 (0xc0000000);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: Updating PCIe dma-ranges\n", __func__));
|
||||
|
||||
@@ -371,7 +372,7 @@ SyncPcie (
|
||||
* around a failure in Linux and OpenBSD to reset the PCIe/XHCI correctly
|
||||
* when in DT mode.
|
||||
*/
|
||||
- Retval = fdt_setprop (mFdtImage, Node, "dma-ranges",
|
||||
+ Retval = FdtSetProp (mFdtImage, Node, "dma-ranges",
|
||||
DmaRanges, sizeof DmaRanges);
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate PCIe 'dma-ranges' property (%d)\n",
|
||||
@@ -380,20 +381,20 @@ SyncPcie (
|
||||
}
|
||||
|
||||
// move the MMIO window too
|
||||
- DmaRanges[0] = cpu_to_fdt32 (0x02000000); // non prefetchable 32-bit
|
||||
- DmaRanges[1] = cpu_to_fdt32 (FixedPcdGet64 (PcdBcm27xxPciBusMmioAdr) >> 32); // bus addr @ 0x0f8000000
|
||||
- DmaRanges[2] = cpu_to_fdt32 (FixedPcdGet64 (PcdBcm27xxPciBusMmioAdr) & MAX_UINT32);
|
||||
- DmaRanges[3] = cpu_to_fdt32 (FixedPcdGet64 (PcdBcm27xxPciCpuMmioAdr) >> 32); // cpu addr @ 0x600000000
|
||||
- DmaRanges[4] = cpu_to_fdt32 (FixedPcdGet64 (PcdBcm27xxPciCpuMmioAdr) & MAX_UINT32);
|
||||
- DmaRanges[5] = cpu_to_fdt32 (0x00000000);
|
||||
- DmaRanges[6] = cpu_to_fdt32 (FixedPcdGet32 (PcdBcm27xxPciBusMmioLen) + 1); // len = 0x4000 0000
|
||||
+ DmaRanges[0] = CpuToFdt32 (0x02000000); // non prefetchable 32-bit
|
||||
+ DmaRanges[1] = CpuToFdt32 (FixedPcdGet64 (PcdBcm27xxPciBusMmioAdr) >> 32); // bus addr @ 0x0f8000000
|
||||
+ DmaRanges[2] = CpuToFdt32 (FixedPcdGet64 (PcdBcm27xxPciBusMmioAdr) & MAX_UINT32);
|
||||
+ DmaRanges[3] = CpuToFdt32 (FixedPcdGet64 (PcdBcm27xxPciCpuMmioAdr) >> 32); // cpu addr @ 0x600000000
|
||||
+ DmaRanges[4] = CpuToFdt32 (FixedPcdGet64 (PcdBcm27xxPciCpuMmioAdr) & MAX_UINT32);
|
||||
+ DmaRanges[5] = CpuToFdt32 (0x00000000);
|
||||
+ DmaRanges[6] = CpuToFdt32 (FixedPcdGet32 (PcdBcm27xxPciBusMmioLen) + 1); // len = 0x4000 0000
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: Updating PCIe ranges\n", __func__));
|
||||
|
||||
/*
|
||||
* Match ranges (BAR/MMIO) with the EDK2+ACPI setup we are using.
|
||||
*/
|
||||
- Retval = fdt_setprop (mFdtImage, Node, "ranges",
|
||||
+ Retval = FdtSetProp (mFdtImage, Node, "ranges",
|
||||
DmaRanges, sizeof DmaRanges);
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to locate PCIe MMIO 'ranges' property (%d)\n",
|
||||
@@ -418,12 +419,12 @@ SyncPcie (
|
||||
* triggering the mailbox by removing the node.
|
||||
*/
|
||||
|
||||
- Node = fdt_path_offset (mFdtImage, "/scb/pcie@7d500000/pci");
|
||||
+ Node = FdtPathOffset (mFdtImage, "/scb/pcie@7d500000/pci");
|
||||
if (Node < 0) {
|
||||
// This can happen on CM4/etc which doesn't have an onboard XHCI
|
||||
DEBUG ((DEBUG_INFO, "%a: failed to locate /scb/pcie@7d500000/pci\n", __func__));
|
||||
} else {
|
||||
- Retval = fdt_del_node (mFdtImage, Node);
|
||||
+ Retval = FdtDelNode (mFdtImage, Node);
|
||||
if (Retval != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to remove /scb/pcie@7d500000/pci\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
@@ -483,7 +484,7 @@ FdtDxeInitialize (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- FdtSize = fdt_totalsize (FdtImage);
|
||||
+ FdtSize = FdtTotalSize (FdtImage);
|
||||
DEBUG ((DEBUG_INFO, "Devicetree passed via config.txt (0x%lx bytes)\n", FdtSize));
|
||||
|
||||
/*
|
||||
@@ -497,9 +498,9 @@ FdtDxeInitialize (
|
||||
goto out;
|
||||
}
|
||||
|
||||
- Retval = fdt_open_into (FdtImage, mFdtImage, FdtSize);
|
||||
+ Retval = FdtOpenInto (FdtImage, mFdtImage, FdtSize);
|
||||
if (Retval != 0) {
|
||||
- DEBUG ((DEBUG_ERROR, "fdt_open_into failed: %d\n", Retval));
|
||||
+ DEBUG ((DEBUG_ERROR, "FdtOpenInto failed: %d\n", Retval));
|
||||
goto out;
|
||||
}
|
||||
|
||||
diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
index 1ea2fe40..bcc29318 100644
|
||||
--- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
+++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
+ BaseMemoryLib
|
||||
BoardInfoLib
|
||||
BoardRevisionHelperLib
|
||||
DebugLib
|
||||
diff --git a/Platform/RaspberryPi/Library/BoardInfoLib/BoardInfoLib.c b/Platform/RaspberryPi/Library/BoardInfoLib/BoardInfoLib.c
|
||||
index 514ad7fe..197cb97c 100644
|
||||
--- a/Platform/RaspberryPi/Library/BoardInfoLib/BoardInfoLib.c
|
||||
+++ b/Platform/RaspberryPi/Library/BoardInfoLib/BoardInfoLib.c
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <Uefi.h>
|
||||
#include <Library/BoardInfoLib.h>
|
||||
#include <Library/FdtPlatformLib.h>
|
||||
-#include <libfdt.h>
|
||||
+#include <Library/FdtLib.h>
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@@ -27,19 +27,19 @@ BoardInfoGetRevisionCode (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Node = fdt_path_offset (Fdt, "/system");
|
||||
+ Node = FdtPathOffset (Fdt, "/system");
|
||||
if (Node < 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Property = fdt_getprop (Fdt, Node, "linux,revision", &Length);
|
||||
+ Property = FdtGetProp (Fdt, Node, "linux,revision", &Length);
|
||||
if (Property == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
} else if (Length != sizeof (UINT32)) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
- *RevisionCode = fdt32_to_cpu (*(UINT32 *) Property);
|
||||
+ *RevisionCode = Fdt32ToCpu (*(UINT32 *) Property);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -60,19 +60,19 @@ BoardInfoGetSerialNumber (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Node = fdt_path_offset (Fdt, "/system");
|
||||
+ Node = FdtPathOffset (Fdt, "/system");
|
||||
if (Node < 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
- Property = fdt_getprop (Fdt, Node, "linux,serial", &Length);
|
||||
+ Property = FdtGetProp (Fdt, Node, "linux,serial", &Length);
|
||||
if (Property == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
} else if (Length != sizeof (UINT64)) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
- *SerialNumber = fdt64_to_cpu (*(UINT64 *) Property);
|
||||
+ *SerialNumber = Fdt64ToCpu (*(UINT64 *) Property);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
diff --git a/Platform/RaspberryPi/Library/FdtPlatformLib/FdtPlatformLib.c b/Platform/RaspberryPi/Library/FdtPlatformLib/FdtPlatformLib.c
|
||||
index 7d148c01..af14df8c 100644
|
||||
--- a/Platform/RaspberryPi/Library/FdtPlatformLib/FdtPlatformLib.c
|
||||
+++ b/Platform/RaspberryPi/Library/FdtPlatformLib/FdtPlatformLib.c
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/FdtPlatformLib.h>
|
||||
-#include <libfdt.h>
|
||||
+#include <Library/FdtLib.h>
|
||||
|
||||
VOID *
|
||||
EFIAPI
|
||||
@@ -21,10 +21,10 @@ FdtPlatformGetBase (
|
||||
|
||||
Fdt = (VOID *)(UINTN) PcdGet32 (PcdFdtBaseAddress);
|
||||
|
||||
- FdtError = fdt_check_header (Fdt);
|
||||
+ FdtError = FdtCheckHeader (Fdt);
|
||||
if (FdtError != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Bad/missing FDT at 0x%p! Ret=%a\n",
|
||||
- __func__, Fdt, fdt_strerror (FdtError)));
|
||||
+ __func__, Fdt, FdtStrerror (FdtError)));
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
}
|
||||
diff --git a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
|
||||
index d39210c7..ecb03d8c 100644
|
||||
--- a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
|
||||
+++ b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
|
||||
@@ -25,6 +25,7 @@
|
||||
ArmPkg/ArmPkg.dec
|
||||
ArmPlatformPkg/ArmPlatformPkg.dec
|
||||
Platform/RaspberryPi/RaspberryPi.dec
|
||||
+ UefiCpuPkg/UefiCpuPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
index 9e26828b..57280db9 100644
|
||||
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
@@ -52,7 +52,6 @@
|
||||
UefiLib
|
||||
|
||||
[FeaturePcd]
|
||||
- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
|
||||
|
||||
[FixedPcd]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 1cd72681..9b8a09f1 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -274,8 +274,6 @@
|
||||
## If TRUE, Graphics Output Protocol will be installed on virtual handle created by ConsplitterDxe.
|
||||
# It could be set FALSE to save size.
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
|
||||
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
|
||||
- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000
|
||||
@@ -384,7 +382,6 @@
|
||||
|
||||
[PcdsFeatureFlag.common]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
|
||||
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
@@ -574,10 +571,7 @@
|
||||
ArmPkg/Drivers/ArmGicDxe/ArmGicV2Dxe.inf
|
||||
Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
|
||||
Platform/RaspberryPi/RPi5/Drivers/RpiPlatformDxe/RpiPlatformDxe.inf
|
||||
- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf {
|
||||
- <LibraryClasses>
|
||||
- FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf # Map to deprecated library for this module only
|
||||
- }
|
||||
+ Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
|
||||
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
|
||||
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
|
||||
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
|
||||
--
|
||||
2.51.2
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
From fae92c2a574f4e3eeb31fdf37898eaa4720141f7 Mon Sep 17 00:00:00 2001
|
||||
From: Matt P <svidasultaresurge@gmail.com>
|
||||
Date: Fri, 1 Aug 2025 13:27:32 +0100
|
||||
Subject: [PATCH 29/29] add ArmTransferListLib for PeilessSec
|
||||
|
||||
---
|
||||
Platform/RaspberryPi/RPi5/RPi5.dsc | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/Platform/RaspberryPi/RPi5/RPi5.dsc b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
index 9b8a09f1..519eb46c 100644
|
||||
--- a/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
+++ b/Platform/RaspberryPi/RPi5/RPi5.dsc
|
||||
@@ -127,6 +127,7 @@
|
||||
DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
|
||||
TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
|
||||
ArmSmcLib|MdePkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||
+ ArmTransferListLib|ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.inf
|
||||
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
|
||||
|
||||
# Dual serial port library
|
||||
--
|
||||
2.51.2
|
||||
|
||||
Reference in New Issue
Block a user