uefi stuff

This commit is contained in:
mjallen18
2026-01-07 21:28:20 -06:00
parent e76f74e63a
commit ca17f0fe18
35 changed files with 28449 additions and 18 deletions

View File

@@ -1,11 +1,12 @@
{ stdenv
, fetchFromGitHub
, MODEL ? "3"
, lib
, MODEL ? "5"
, DEBUG ? "0"
, TFA_FLAGS ? ""
, lib
}:
stdenv.mkDerivation (_finalAttrs: rec {
stdenv.mkDerivation rec {
pname = "arm-trusted-firmware";
version = "2.14";
@@ -16,11 +17,14 @@ stdenv.mkDerivation (_finalAttrs: rec {
hash = "sha256-7imeQocGMSyGXTEhNs4s0bcDxZpbLSSkOyI7c5UxqVs=";
};
# buildInputs = [
# dtc # dtmerge depends on libfdt
# ];
# Add required host tools if needed:
nativeBuildInputs = [ /* dtc python3 openssl etc. */ ];
buildPhase = ''
make \
CROSS_COMPILE=${stdenv.cc.targetPrefix} \
CC=${stdenv.cc.targetPrefix}cc \
AS=${stdenv.cc.targetPrefix}cc \
PLAT=rpi${MODEL} \
PRELOADED_BL33_BASE=0x20000 \
RPI3_PRELOADED_DTB_BASE=0x3E0000 \
@@ -34,20 +38,13 @@ stdenv.mkDerivation (_finalAttrs: rec {
installPhase = ''
mkdir -p $out
ls -alh
# # Adjust paths as needed. Example:
# cp -r build/rpi${MODEL}/* $out/
cp -r build/* $out/
'';
meta = with lib; {
description = "A collection of scripts and simple applications for Raspberry Pi hardware";
homepage = "https://github.com/raspberrypi/utils";
description = "ARM Trusted Firmware-A for Raspberry Pi";
license = licenses.bsd3;
platforms = [
"armv6l-linux"
"armv7l-linux"
"aarch64-linux"
];
platforms = [ "aarch64-linux" ];
maintainers = with maintainers; [ kazenyuk ];
};
})
}

116
packages/edk2/default.nix Normal file
View File

@@ -0,0 +1,116 @@
{ stdenv
, fetchFromGitHub
, lib
, MODEL ? "5"
, RELEASE_TYPE ? "RELEASE"
, EDK2_FLAGS ? ""
, python3
, git
, libuuid
, pkgs
, namespace
}:
let
pname = "edk2";
version = "stable202511";
edk2Src = fetchFromGitHub rec {
owner = "tianocore";
repo = "edk2";
name = repo;
tag = "edk2-${version}";
hash = "sha256-R/rgz8dWcDYVoiM67K2UGuq0xXbjjJYBPtJ1FmfGIaU=";
fetchSubmodules = true;
};
edk2NonOsiSrc = fetchFromGitHub rec {
owner = "tianocore";
repo = "edk2-non-osi";
name = repo;
rev = "94d048981116e2e3eda52dad1a89958ee404098d";
hash = "sha256-6yuvVvmGn4yaEksbbvGDX1ZcKpdWBKnwaNjLGvgAWyk=";
};
edk2PlatformsSrc = fetchFromGitHub rec {
owner = "mjallen18";
repo = "edk2-platforms";
name = repo;
rev = "779690d3316f56e9100949b5daf13d6c2fc0ddf6";
hash = "sha256-UqvN9p4wXN/TQt47bc2l+pAjhGZRbKwmq0DkBvTV4r0=";
};
in
stdenv.mkDerivation rec {
inherit pname version;
srcs = [
edk2Src
edk2NonOsiSrc
edk2PlatformsSrc
];
# Add required host tools if needed:
nativeBuildInputs = [
python3
git
libuuid
];
# Dont force a single root; we keep both dirs side by side
sourceRoot = ".";
unpackPhase = ''
runHook preUnpack
for src in $srcs; do
unpackFile "$src"
done
chmod -R u+w .
runHook postUnpack
'';
patchPhase = ''
runHook prePatch
echo "Patching edk2"
(cd edk2 && patch -p1 < ${./patches/0001-SD-fixup.patch})
echo "Patching edk2-non-osi"
(cd edk2-non-osi && git apply --binary ${./patches/non-osi/0001-Add-RPi5.patch})
(cd edk2-non-osi && git apply --binary ${./patches/non-osi/0002-update-bl31.bin-for-new-DTB-address.patch})
runHook postPatch
'';
buildPhase = ''
export PYTHON_COMMAND=${python3}/bin/python
make -C ./edk2/BaseTools
export ATF_BUILD_DIR="${pkgs.${namespace}.arm-trusted-firmware}/rpi${MODEL}/${RELEASE_TYPE}"
source ./edk2/edksetup.sh
build \
-a AARCH64 \
-t GCC \
-b ${RELEASE_TYPE} \
-p edk2-platforms/Platform/RaspberryPi/RPi${MODEL}/RPi${MODEL}.dsc \
-D TFA_BUILD_ARTIFACTS=$ATF_BUILD_DIR \
--pcd gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString=Lunknown \
${EDK2_FLAGS}
'';
installPhase = ''
mkdir -p $out
cp -r /Build/RPi${MODEL}/${RELEASE_TYPE}_GCC/FV/RPI_EFI.fd $out/RPI_EFI.fd
'';
meta = with lib; {
description = "ARM Trusted Firmware-A for Raspberry Pi";
license = licenses.bsd3;
platforms = [ "aarch64-linux" ];
maintainers = with maintainers; [ kazenyuk ];
};
}

View File

@@ -0,0 +1,257 @@
From cea64af8854a7785e6ac3ecdcc47f46779940b21 Mon Sep 17 00:00:00 2001
From: mattp <svidasultaresurge@gmail.com>
Date: Fri, 18 Jul 2025 08:23:43 -0400
Subject: [PATCH] SD fixup
---
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 32 ++++----
.../Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 77 +++++++++++++++++++
.../Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h | 28 ++++++-
MdeModulePkg/Include/Protocol/SdMmcOverride.h | 10 ++-
4 files changed, 128 insertions(+), 19 deletions(-)
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
index 8bf452e9d0..acb98c4a6a 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
@@ -1215,6 +1215,7 @@ SdCardIdentification (
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;
+ EFI_HANDLE ControllerHandle;
UINT32 Ocr;
UINT16 Rca;
BOOLEAN Xpc;
@@ -1223,7 +1224,6 @@ SdCardIdentification (
UINT16 ControllerVer;
UINT8 PowerCtrl;
UINT32 PresentState;
- UINT8 HostCtrl2;
UINTN Retry;
BOOLEAN ForceVoltage33;
BOOLEAN SdVersion1;
@@ -1231,10 +1231,22 @@ SdCardIdentification (
ForceVoltage33 = FALSE;
SdVersion1 = FALSE;
- PciIo = Private->PciIo;
- PassThru = &Private->PassThru;
+ PciIo = Private->PciIo;
+ PassThru = &Private->PassThru;
+ ControllerHandle = Private->ControllerHandle;
Voltage33Retry:
+ //
+ // Start at 3.3V.
+ // Note that if we got here from a failed 1.8V switching attempt,
+ // the card should've been power cycled to reset its own voltage level.
+ //
+ Status = SdMmcHcSetSignalingVoltage (ControllerHandle, PciIo, Slot, SdMmcSignalingVoltage33);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "SdCardIdentification: Couldn't set 3.3V signaling: %r\n", Status));
+ return Status;
+ }
+
//
// 1. Send Cmd0 to the device
//
@@ -1371,16 +1383,10 @@ Voltage33Retry:
goto Error;
}
- HostCtrl2 = BIT3;
- SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
-
- gBS->Stall (5000);
-
- SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2);
- if ((HostCtrl2 & BIT3) == 0) {
- DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with HostCtrl2 = 0x%x\n", HostCtrl2));
- Status = EFI_DEVICE_ERROR;
- goto Error;
+ Status = SdMmcHcSetSignalingVoltage (ControllerHandle, PciIo, Slot, SdMmcSignalingVoltage18);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "SdCardIdentification: Couldn't set 1.8V signaling: %r\n", Status));
+ return Status;
}
Status = SdMmcHcStartSdClock (PciIo, Slot);
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
index 9e8a7f4e43..2e334c67e2 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
@@ -1175,6 +1175,83 @@ SdMmcHcInitPowerVoltage (
return Status;
}
+/**
+ Set the voltage regulator for I/O signaling.
+
+ @param[in] PciIo The PCI IO protocol instance.
+ @param[in] Slot The slot number of the SD card to send the command to.
+ @param[in] Voltage The signaling voltage.
+
+ @retval EFI_SUCCESS The voltage is supplied successfully.
+ @retval Others The voltage isn't supplied successfully.
+
+**/
+EFI_STATUS
+SdMmcHcSetSignalingVoltage (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Slot,
+ IN SD_MMC_SIGNALING_VOLTAGE Voltage
+ )
+{
+ EFI_STATUS Status;
+ UINT8 HostCtrl2;
+
+ //
+ // Set the internal regulator first.
+ //
+ switch (Voltage) {
+ case SdMmcSignalingVoltage33:
+ HostCtrl2 = ~SD_MMC_HC_CTRL_1V8_SIGNAL;
+ SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
+ break;
+ case SdMmcSignalingVoltage18:
+ HostCtrl2 = SD_MMC_HC_CTRL_1V8_SIGNAL;
+ SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
+ break;
+ default:
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Some controllers rely on an external regulator.
+ //
+ if ((mOverride != NULL) && (mOverride->NotifyPhase != NULL)) {
+ Status = mOverride->NotifyPhase (
+ ControllerHandle,
+ Slot,
+ EdkiiSdMmcSetSignalingVoltage,
+ &Voltage
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: SD/MMC set signaling voltage notifier callback failed - %r\n",
+ __func__,
+ Status
+ ));
+ return Status;
+ }
+ }
+
+ gBS->Stall (5000);
+
+ Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ HostCtrl2 &= SD_MMC_HC_CTRL_1V8_SIGNAL;
+ if (((Voltage == SdMmcSignalingVoltage33) && (HostCtrl2 != 0)) ||
+ ((Voltage == SdMmcSignalingVoltage18) && (HostCtrl2 == 0)))
+ {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
/**
Initialize the Timeout Control register with most conservative value at initialization.
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
index e436a7d11a..e771ba7bad 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h
@@ -2,10 +2,10 @@
Provides some data structure definitions used by the SD/MMC host controller driver.
- Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
- Copyright (C) 2023, Apple Inc. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
+Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (C) 2023, Apple Inc. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
@par Specification Reference:
- SD Host Controller Simplified Specification, Version 4.20, July 25, 2018
@@ -63,6 +63,7 @@
//
// SD Host Controller bits to HOST_CTRL2 register
//
+#define SD_MMC_HC_CTRL_1V8_SIGNAL 0x0008
#define SD_MMC_HC_CTRL_UHS_MASK 0x0007
#define SD_MMC_HC_CTRL_UHS_SDR12 0x0000
#define SD_MMC_HC_CTRL_UHS_SDR25 0x0001
@@ -559,6 +560,25 @@ SdMmcHcInitPowerVoltage (
IN SD_MMC_HC_SLOT_CAP Capability
);
+/**
+ Set the voltage regulator for I/O signaling.
+
+ @param[in] PciIo The PCI IO protocol instance.
+ @param[in] Slot The slot number of the SD card to send the command to.
+ @param[in] Voltage The signaling voltage.
+
+ @retval EFI_SUCCESS The voltage is supplied successfully.
+ @retval Others The voltage isn't supplied successfully.
+
+**/
+EFI_STATUS
+SdMmcHcSetSignalingVoltage (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Slot,
+ IN SD_MMC_SIGNALING_VOLTAGE Voltage
+ );
+
/**
Initialize the Timeout Control register with most conservative value at initialization.
diff --git a/MdeModulePkg/Include/Protocol/SdMmcOverride.h b/MdeModulePkg/Include/Protocol/SdMmcOverride.h
index 4fd12b9ad4..d611bb04d8 100644
--- a/MdeModulePkg/Include/Protocol/SdMmcOverride.h
+++ b/MdeModulePkg/Include/Protocol/SdMmcOverride.h
@@ -16,7 +16,7 @@
#define EDKII_SD_MMC_OVERRIDE_PROTOCOL_GUID \
{ 0xeaf9e3c1, 0xc9cd, 0x46db, { 0xa5, 0xe5, 0x5a, 0x12, 0x4c, 0x83, 0x23, 0x23 } }
-#define EDKII_SD_MMC_OVERRIDE_PROTOCOL_VERSION 0x3
+#define EDKII_SD_MMC_OVERRIDE_PROTOCOL_VERSION 0x4
typedef struct _EDKII_SD_MMC_OVERRIDE EDKII_SD_MMC_OVERRIDE;
@@ -83,6 +83,11 @@ typedef enum {
SdMmcMmcHs400,
} SD_MMC_BUS_MODE;
+typedef enum {
+ SdMmcSignalingVoltage33,
+ SdMmcSignalingVoltage18
+} SD_MMC_SIGNALING_VOLTAGE;
+
typedef enum {
EdkiiSdMmcResetPre,
EdkiiSdMmcResetPost,
@@ -90,7 +95,8 @@ typedef enum {
EdkiiSdMmcInitHostPost,
EdkiiSdMmcUhsSignaling,
EdkiiSdMmcSwitchClockFreqPost,
- EdkiiSdMmcGetOperatingParam
+ EdkiiSdMmcGetOperatingParam,
+ EdkiiSdMmcSetSignalingVoltage
} EDKII_SD_MMC_PHASE_TYPE;
/**
--
2.51.2

View File

@@ -0,0 +1,376 @@
From cfc24a5bf9eb23a9e9060ea1c5fcc9f51f208d18 Mon Sep 17 00:00:00 2001
From: mattp <svidasultaresurge@gmail.com>
Date: Thu, 17 Jul 2025 15:04:10 -0400
Subject: [PATCH 1/2] Add RPi5
---
.../RPi5/TrustedFirmware/License.txt | 26 ++++++++++++++++++
.../RaspberryPi/RPi5/TrustedFirmware/bl31.bin | Bin 0 -> 32878 bytes
2 files changed, 26 insertions(+)
create mode 100644 Platform/RaspberryPi/RPi5/TrustedFirmware/License.txt
create mode 100755 Platform/RaspberryPi/RPi5/TrustedFirmware/bl31.bin
diff --git a/Platform/RaspberryPi/RPi5/TrustedFirmware/License.txt b/Platform/RaspberryPi/RPi5/TrustedFirmware/License.txt
new file mode 100644
index 0000000..4842997
--- /dev/null
+++ b/Platform/RaspberryPi/RPi5/TrustedFirmware/License.txt
@@ -0,0 +1,26 @@
+Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+
+* Neither the name of ARM nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Platform/RaspberryPi/RPi5/TrustedFirmware/bl31.bin b/Platform/RaspberryPi/RPi5/TrustedFirmware/bl31.bin
new file mode 100755
index 0000000000000000000000000000000000000000..3d1c76972c4bdf76d45e473d25757036e52b8abb
GIT binary patch
literal 32878
zcmZQzVGv;$L4Z5_U(^Wl?x<HsLtr!nMnhmU1V%$(Gz3ONU^E0qLtr!nMnhmU1V%#u
z90FgM8CHE|W?c1+nQ7H`X6984Y>k%|NG$urARu@3zCH8RMka<S4h#%i7#QTQEvRD>
zU^oB~pT)#5MV^Ua3KNUNPX`A3YmSUfmly=>t}-w%u7c_9Vq%!W$kA|#p@wm`BLl++
zMFysc3=E9j4j1IEGO#sVVi1(O%D}Mbl7g_@RfdL!OAJgqJ~;@=UH$LEd{tlA?&^ES
zf=&9ua##5ULG0R1?-|QC@e9gb<)34H^*v+tCjL3nSN*|q6`S5OmTY?evviWbAjExX
zObk;J7#K`J?%&JEFl8bW!xRMuh7Sx33=<m}7$zt(FiccrU^uM}@!tmq2BwK%H#*pX
z#m$)+rtEiMxLU--Fy#TW$f}3TqN^S;i>-RhEWYY1GsBcFW`uc)AiwQk1nW~~1cw)f
zd9sWQQwkUvL>fvEVd%-kFy$O0{xGy0z%T^)-w5n~`BiHf7^e8~Gfc5(gp3!xXO>&V
zz+iEeFDBqJACJT42h4n{jxjJydCttYN`aYSO9Df~C59hz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Hx(wK_V8A><VIn@eeUD#Q>vM6hinriXikTIT`|^Aut*OqaiRF0;3@?
z8UmvsFtS77KL{`|Fo3B43=9kzXCUDL@5f(&@L3=fL&JFp1JVzLu(6RK^FZRDRxGHi
I38EQU02$>0ga7~l
literal 0
HcmV?d00001
--
2.51.2

View File

@@ -0,0 +1,23 @@
From 1e089448a4c82b473da6fb31a5058b65f38bc79a Mon Sep 17 00:00:00 2001
From: mattp <svidasultaresurge@gmail.com>
Date: Thu, 17 Jul 2025 19:47:29 -0400
Subject: [PATCH 2/2] update bl31.bin for new DTB address
---
.../RaspberryPi/RPi5/TrustedFirmware/bl31.bin | Bin 32878 -> 32878 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/Platform/RaspberryPi/RPi5/TrustedFirmware/bl31.bin b/Platform/RaspberryPi/RPi5/TrustedFirmware/bl31.bin
index 3d1c76972c4bdf76d45e473d25757036e52b8abb..f5a2d603a358bb785345950157a9df95bf2e1dd5 100755
GIT binary patch
delta 54
zcmaFY!1S(xX@ieE(*gF)e)1xLoOTQlV7EED;3<oMp{13Hsg;4Dj)GTdj)I~2=7dr{
FZUC|{4xRu2
delta 54
zcmaFY!1S(xX@ieE(*x$se)1xLobn71Aip`g;3<oMfu)tHp_QSLj)GTdj)I}-=7dr{
FZUC<i4tM|n
--
2.51.2

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View 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

File diff suppressed because it is too large Load Diff

View 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

View 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

View File

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

View File

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

View File

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

View File

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

View File

@@ -10,7 +10,7 @@
# bootloader = "kernel";
# firmwarePackage = pkgs.raspberrypifw;
# };
kernelPackages = pkgs.${namespace}.linuxPackages_cachyos-server-lto;
kernelPackages = pkgs.linuxPackages_latest;
#supportedFilesystems = lib.mkForce [ ];
};