diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c index 2e70c4533c..2fd6f7d66f 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c @@ -8,84 +8,6 @@ **/ #include "BlSupportDxe.h" -/** - Reserve MMIO/IO resource in GCD - - @param IsMMIO Flag of whether it is mmio resource or io resource. - @param GcdType Type of the space. - @param BaseAddress Base address of the space. - @param Length Length of the space. - @param Alignment Align with 2^Alignment - @param ImageHandle Handle for the image of this driver. - - @retval EFI_SUCCESS Reserve successful -**/ -EFI_STATUS -ReserveResourceInGcd ( - IN BOOLEAN IsMMIO, - IN UINTN GcdType, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINTN Alignment, - IN EFI_HANDLE ImageHandle - ) -{ - EFI_STATUS Status; - - if (IsMMIO) { - Status = gDS->AddMemorySpace ( - GcdType, - BaseAddress, - Length, - EFI_MEMORY_UC - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_WARN, - "Failed to add memory space :0x%lx 0x%lx\n", - BaseAddress, - Length - )); - } - - Status = gDS->AllocateMemorySpace ( - EfiGcdAllocateAddress, - GcdType, - Alignment, - Length, - &BaseAddress, - ImageHandle, - NULL - ); - } else { - Status = gDS->AddIoSpace ( - GcdType, - BaseAddress, - Length - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_WARN, - "Failed to add IO space :0x%lx 0x%lx\n", - BaseAddress, - Length - )); - } - - Status = gDS->AllocateIoSpace ( - EfiGcdAllocateAddress, - GcdType, - Alignment, - Length, - &BaseAddress, - ImageHandle, - NULL - ); - } - - return Status; -} - /** Main entry for the bootloader support DXE module. @@ -109,12 +31,6 @@ BlDxeEntryPoint ( ACPI_BOARD_INFO *AcpiBoardInfo; Status = EFI_SUCCESS; - // - // Report MMIO/IO Resources - // - ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC - - ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET // // Find the frame buffer information and update PCDs @@ -144,5 +60,8 @@ BlDxeEntryPoint ( ASSERT_EFI_ERROR (Status); } + Status = BlArchAdditionalOps (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h index 4d2d05d907..ebae6f2b5e 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h @@ -24,4 +24,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include +EFI_STATUS +EFIAPI +BlArchAdditionalOps ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + #endif diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf index 96d85d2b1d..43b69e62d8 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf @@ -27,6 +27,9 @@ BlSupportDxe.c BlSupportDxe.h +[Sources.IA32, Sources.X64] + X86/BlSupport.c + [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec diff --git a/UefiPayloadPkg/BlSupportDxe/X86/BlSupport.c b/UefiPayloadPkg/BlSupportDxe/X86/BlSupport.c new file mode 100644 index 0000000000..56d4c71822 --- /dev/null +++ b/UefiPayloadPkg/BlSupportDxe/X86/BlSupport.c @@ -0,0 +1,115 @@ +/** @file + This file will report some MMIO/IO resources to dxe core. + + Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ Copyright 2025 Google LLC + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include "BlSupportDxe.h" + +/** + Reserve MMIO/IO resource in GCD + + @param IsMMIO Flag of whether it is mmio resource or io resource. + @param GcdType Type of the space. + @param BaseAddress Base address of the space. + @param Length Length of the space. + @param Alignment Align with 2^Alignment + @param ImageHandle Handle for the image of this driver. + + @retval EFI_SUCCESS Reserve successful +**/ +EFI_STATUS +ReserveResourceInGcd ( + IN BOOLEAN IsMMIO, + IN UINTN GcdType, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINTN Alignment, + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + if (IsMMIO) { + Status = gDS->AddMemorySpace ( + GcdType, + BaseAddress, + Length, + EFI_MEMORY_UC + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_WARN, + "Failed to add memory space :0x%lx 0x%lx\n", + BaseAddress, + Length + )); + } + + Status = gDS->AllocateMemorySpace ( + EfiGcdAllocateAddress, + GcdType, + Alignment, + Length, + &BaseAddress, + ImageHandle, + NULL + ); + } else { + Status = gDS->AddIoSpace ( + GcdType, + BaseAddress, + Length + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_WARN, + "Failed to add IO space :0x%lx 0x%lx\n", + BaseAddress, + Length + )); + } + + Status = gDS->AllocateIoSpace ( + EfiGcdAllocateAddress, + GcdType, + Alignment, + Length, + &BaseAddress, + ImageHandle, + NULL + ); + } + + return Status; +} + +/** + Architecture level additional operation which needs to be performed before + launching payload. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +EFIAPI +BlArchAdditionalOps ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // Report MMIO/IO Resources + // + ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC + + ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET + + return EFI_SUCCESS; +}