When SaSbQemu platform is configured with multi memory nodes,like numa architecture, os will ignore any memory node in the device tree except the first one.The kernel reads UEFI memory map for memory information when booting via UEFI.However UEFI only allocates the first memory node memory space for SbsaQemu platform, in this scenario we can full use of HighMemDxe to add memory spaces for other memory nodes.
Changes in V2: - Modify the the execution order of PlatformPeiLib moodule after memory initialization
xiongyining1480 (3): SbsaQemu: Use HighMemDxe provided by OvmfPkg SbsaQemu: Use FdtClientDxe provided by EmbeddedPkg SbsaQemu: Add PlatformPeiLib library
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 8 ++- Platform/Qemu/SbsaQemu/SbsaQemu.fdf | 2 + .../Library/PlatformPeiLib/PlatformPeiLib.c | 63 +++++++++++++++++++ .../Library/PlatformPeiLib/PlatformPeiLib.inf | 41 ++++++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.c create mode 100644 Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.inf
Use HighMemDxe library to add memory space for the high memory nodes.
Signed-off-by: Xiong Yining xiongyining1480@phytium.com.cn Signed-off-by: Chen Baozi chenbaozi@phytium.com.cn --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 5 +++++ Platform/Qemu/SbsaQemu/SbsaQemu.fdf | 1 + 2 files changed, 6 insertions(+)
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc index fa85bd8dab..b1f638ad69 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -675,6 +675,11 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+ # + # Platform Driver + # + OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf + # # FAT filesystem + GPT/MBR partitioning # diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf index 6fcfd25faa..adc5fd7801 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf @@ -161,6 +161,7 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Core/Dxe/DxeMain.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf
# # PI DXE Drivers producing Architectural Protocols (EFI Services)
Add FdtClientDxe to the SbsaQemu platforms,so that we can use the FDT client protocol to parse the fdt.
Signed-off-by: Xiong Yining xiongyining1480@phytium.com.cn Signed-off-by: Chen Baozi chenbaozi@phytium.com.cn --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 1 + Platform/Qemu/SbsaQemu/SbsaQemu.fdf | 1 + 2 files changed, 2 insertions(+)
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc index b1f638ad69..10c61d0eb6 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -678,6 +678,7 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE # # Platform Driver # + EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf
# diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf index adc5fd7801..36d2c46e24 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf @@ -161,6 +161,7 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Core/Dxe/DxeMain.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + INF EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf INF OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf
#
This is a fork of the ARM PlatformPeiLib for SbsaQemu platform.The main purpose of having this specific implementation is that it allows us to pass DTB to DXE via HOB.
Signed-off-by: Xiong Yining xiongyining1480@phytium.com.cn Signed-off-by: Chen Baozi chenbaozi@phytium.com.cn --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 2 +- .../Library/PlatformPeiLib/PlatformPeiLib.c | 63 +++++++++++++++++++ .../Library/PlatformPeiLib/PlatformPeiLib.inf | 41 ++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.c create mode 100644 Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.inf
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc index 10c61d0eb6..fcbeb24c97 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -115,7 +115,7 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf
- PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf + PlatformPeiLib|Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.inf MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf ResetSystemLib|ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf
diff --git a/Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.c b/Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.c new file mode 100644 index 0000000000..66de307e73 --- /dev/null +++ b/Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.c @@ -0,0 +1,63 @@ +/** @file + SbsaQemu PlatformPeiLib library. + + Copyright (c) 2023, Phytium. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include <PiPei.h> +#include <Guid/FdtHob.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/DebugLib.h> +#include <Library/HobLib.h> +#include <Library/PcdLib.h> +#include <libfdt.h> + +/** Initialise Platform HOBs + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Out of resources. +**/ +EFI_STATUS +EFIAPI +PlatformPeim ( + VOID + ) +{ + VOID *Base; + VOID *NewBase; + UINTN FdtSize; + UINTN FdtPages; + UINT64 *FdtHobData; + + Base = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress); + if ((Base == NULL) || (fdt_check_header (Base) != 0)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + FdtSize = fdt_totalsize (Base); + FdtPages = EFI_SIZE_TO_PAGES (FdtSize); + NewBase = AllocatePages (FdtPages); + if (NewBase == NULL) { + ASSERT (0); + return EFI_OUT_OF_RESOURCES; + } + + fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages)); + + FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData)); + if (FdtHobData == NULL) { + ASSERT (0); + return EFI_OUT_OF_RESOURCES; + } + + *FdtHobData = (UINTN)NewBase; + + BuildFvHob (FixedPcdGet64 (PcdFvBaseAddress), FixedPcdGet32 (PcdFvSize)); + + return EFI_SUCCESS; +} diff --git a/Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.inf b/Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.inf new file mode 100644 index 0000000000..ac594b423a --- /dev/null +++ b/Silicon/Qemu/SbsaQemu/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -0,0 +1,41 @@ +#/** @file +# +# Copyright (c) 2023, Linaro Ltd. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PlatformPeiLib + FILE_GUID = 75781B6E-A547-0BB7-0AEF-EFBFD7D8F609 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = PlatformPeiLib + +[Sources] + PlatformPeiLib.c + +[Packages] + ArmPkg/ArmPkg.dec + Silicon/Qemu/SbsaQemu/SbsaQemu.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + HobLib + FdtLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdFvSize + gArmTokenSpaceGuid.PcdFvBaseAddress + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdDeviceTreeBaseAddress + +[Guids] + gFdtHobGuid + +[Depex] + gEfiPeiMemoryDiscoveredPpiGuid