UefiPayloadPkg: Add Architecture layer to support multiple architectures
Move IA32 and X64 architectures specified code to corresponding files. Signed-off-by: Ajan Zhong <ajan.zhong@newfw.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -24,4 +24,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Guid/AcpiBoardInfoGuid.h>
|
||||
#include <Guid/GraphicsInfoHob.h>
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BlArchAdditionalOps (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
BlSupportDxe.c
|
||||
BlSupportDxe.h
|
||||
|
||||
[Sources.IA32, Sources.X64]
|
||||
X86/BlSupport.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
115
UefiPayloadPkg/BlSupportDxe/X86/BlSupport.c
Normal file
115
UefiPayloadPkg/BlSupportDxe/X86/BlSupport.c
Normal file
@@ -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.<BR>
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user