mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 15:44:04 +02:00
• Set the default value of PcdDxeIplSwitchToLongMode to TRUE.
• Make access to PcdDxeIplSwitchToLongMode to Ia32 specific code. • Introduce another feature flag named PcdDxeIplBuildShareCodeHobs to define whether to build hobs to DXE core to share code. • Remove the #progma bug git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2026 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
2109b16ef8
commit
657d3918fe
@ -27,38 +27,6 @@ Abstract:
|
|||||||
|
|
||||||
extern BOOLEAN gInMemory;
|
extern BOOLEAN gInMemory;
|
||||||
|
|
||||||
/**
|
|
||||||
Transfers control to a function starting with a new stack.
|
|
||||||
|
|
||||||
Transfers control to the function specified by EntryPoint using the new stack
|
|
||||||
specified by NewStack and passing in the parameters specified by Context1 and
|
|
||||||
Context2. Context1 and Context2 are optional and may be NULL. The function
|
|
||||||
EntryPoint must never return.
|
|
||||||
|
|
||||||
If EntryPoint is NULL, then ASSERT().
|
|
||||||
If NewStack is NULL, then ASSERT().
|
|
||||||
|
|
||||||
@param EntryPoint A pointer to function to call with the new stack.
|
|
||||||
@param Context1 A pointer to the context to pass into the EntryPoint
|
|
||||||
function.
|
|
||||||
@param Context2 A pointer to the context to pass into the EntryPoint
|
|
||||||
function.
|
|
||||||
@param NewStack A pointer to the new stack to use for the EntryPoint
|
|
||||||
function.
|
|
||||||
@param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
|
|
||||||
Reserved on other architectures.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
SwitchIplStacks (
|
|
||||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
|
||||||
IN VOID *Context1, OPTIONAL
|
|
||||||
IN VOID *Context2, OPTIONAL
|
|
||||||
IN VOID *NewStack,
|
|
||||||
IN VOID *NewBsp
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeiFindFile (
|
PeiFindFile (
|
||||||
IN UINT8 Type,
|
IN UINT8 Type,
|
||||||
@ -79,12 +47,6 @@ PeiLoadFile (
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
CreateArchSpecificHobs (
|
|
||||||
OUT EFI_PHYSICAL_ADDRESS *BspStore
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetImageReadFunction (
|
GetImageReadFunction (
|
||||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||||
@ -124,6 +86,12 @@ DxeLoadCore (
|
|||||||
IN EFI_PEI_HOB_POINTERS HobList
|
IN EFI_PEI_HOB_POINTERS HobList
|
||||||
);
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
HandOffToDxeCore (
|
||||||
|
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
|
||||||
|
IN EFI_PEI_HOB_POINTERS HobList
|
||||||
|
);
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeiProcessFile (
|
PeiProcessFile (
|
||||||
IN UINT16 SectionType,
|
IN UINT16 SectionType,
|
||||||
@ -139,17 +107,6 @@ PeimInitializeDxeIpl (
|
|||||||
IN EFI_PEI_SERVICES **PeiServices
|
IN EFI_PEI_SERVICES **PeiServices
|
||||||
);
|
);
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
PeiLoadx64File (
|
|
||||||
IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader,
|
|
||||||
IN VOID *Pe32Data,
|
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
|
||||||
OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
|
|
||||||
OUT UINT64 *ImageSize,
|
|
||||||
OUT EFI_PHYSICAL_ADDRESS *EntryPoint
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
EFI_PHYSICAL_ADDRESS
|
EFI_PHYSICAL_ADDRESS
|
||||||
CreateIdentityMappingPageTables (
|
CreateIdentityMappingPageTables (
|
||||||
IN UINT32 NumberOfProcessorPhysicalAddressBits
|
IN UINT32 NumberOfProcessorPhysicalAddressBits
|
||||||
|
@ -75,19 +75,15 @@
|
|||||||
<Filename>DxeLoad.c</Filename>
|
<Filename>DxeLoad.c</Filename>
|
||||||
<Filename>DxeIpl.h</Filename>
|
<Filename>DxeIpl.h</Filename>
|
||||||
<Filename>DxeIpl.dxs</Filename>
|
<Filename>DxeIpl.dxs</Filename>
|
||||||
<Filename SupArchList="IA32">Ia32/ImageRead.c</Filename>
|
<Filename SupArchList="IA32 X64 EBC">Ia32/ImageRead.c</Filename>
|
||||||
<Filename SupArchList="IA32">Ia32/DxeLoadFunc.c</Filename>
|
<Filename SupArchList="IA32">Ia32/DxeLoadFunc.c</Filename>
|
||||||
<Filename SupArchList="IA32">Ia32/LongMode.asm</Filename>
|
<Filename SupArchList="IA32">Ia32/LongMode.asm</Filename>
|
||||||
<Filename ToolChainFamily="GCC" SupArchList="IA32">Ia32/LongMode.S</Filename>
|
<Filename ToolChainFamily="GCC" SupArchList="IA32">Ia32/LongMode.S</Filename>
|
||||||
<Filename SupArchList="IA32">Ia32/VirtualMemory.c</Filename>
|
<Filename SupArchList="IA32">Ia32/VirtualMemory.c</Filename>
|
||||||
<Filename SupArchList="IA32">Ia32/VirtualMemory.h</Filename>
|
<Filename SupArchList="IA32">Ia32/VirtualMemory.h</Filename>
|
||||||
<Filename SupArchList="X64">Ia32/ImageRead.c</Filename>
|
<Filename SupArchList="X64 EBC">X64/DxeLoadFunc.c</Filename>
|
||||||
<Filename SupArchList="X64">Ia32/DxeLoadFunc.c</Filename>
|
|
||||||
<Filename SupArchList="IPF">ipf/ImageRead.c</Filename>
|
<Filename SupArchList="IPF">ipf/ImageRead.c</Filename>
|
||||||
<Filename SupArchList="IPF">ipf/DxeLoadFunc.c</Filename>
|
<Filename SupArchList="IPF">ipf/DxeLoadFunc.c</Filename>
|
||||||
<Filename SupArchList="EBC">Ia32/ImageRead.c</Filename>
|
|
||||||
<Filename SupArchList="EBC">Ia32/DxeLoadFunc.c</Filename>
|
|
||||||
<Filename SupArchList="X64 IPF EBC">Non-existing.c</Filename>
|
|
||||||
</SourceFiles>
|
</SourceFiles>
|
||||||
<PackageDependencies>
|
<PackageDependencies>
|
||||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
@ -143,9 +139,15 @@
|
|||||||
<PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">
|
<PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">
|
||||||
<C_Name>PcdDxeIplSwitchToLongMode</C_Name>
|
<C_Name>PcdDxeIplSwitchToLongMode</C_Name>
|
||||||
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
<DefaultValue>FALSE</DefaultValue>
|
<DefaultValue>TRUE</DefaultValue>
|
||||||
<HelpText>If this feature is enabled, then the DXE IPL will load a 64-bit DxeCore.</HelpText>
|
<HelpText>If this feature is enabled, then the DXE IPL will load a 64-bit DxeCore.</HelpText>
|
||||||
</PcdEntry>
|
</PcdEntry>
|
||||||
|
<PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">
|
||||||
|
<C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>
|
||||||
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DefaultValue>TRUE</DefaultValue>
|
||||||
|
<HelpText>If this feature is enabled, DXE IPL will build a series of HOBs to share code with DXE Core.</HelpText>
|
||||||
|
</PcdEntry>
|
||||||
<PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">
|
<PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">
|
||||||
<C_Name>PcdDxeIplSupportEfiDecompress</C_Name>
|
<C_Name>PcdDxeIplSupportEfiDecompress</C_Name>
|
||||||
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
@ -22,10 +22,6 @@ Abstract:
|
|||||||
|
|
||||||
#include "DxeIpl.h"
|
#include "DxeIpl.h"
|
||||||
|
|
||||||
#ifndef __GNUC__
|
|
||||||
#pragma warning( disable : 4305 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOLEAN gInMemory = FALSE;
|
BOOLEAN gInMemory = FALSE;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -151,9 +147,6 @@ Returns:
|
|||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_PHYSICAL_ADDRESS TopOfStack;
|
|
||||||
EFI_PHYSICAL_ADDRESS BaseOfStack;
|
|
||||||
EFI_PHYSICAL_ADDRESS BspStore;
|
|
||||||
EFI_GUID DxeCoreFileName;
|
EFI_GUID DxeCoreFileName;
|
||||||
EFI_GUID FirmwareFileName;
|
EFI_GUID FirmwareFileName;
|
||||||
VOID *Pe32Data;
|
VOID *Pe32Data;
|
||||||
@ -165,13 +158,8 @@ Returns:
|
|||||||
EFI_BOOT_MODE BootMode;
|
EFI_BOOT_MODE BootMode;
|
||||||
EFI_PEI_RECOVERY_MODULE_PPI *PeiRecovery;
|
EFI_PEI_RECOVERY_MODULE_PPI *PeiRecovery;
|
||||||
EFI_PEI_S3_RESUME_PPI *S3Resume;
|
EFI_PEI_S3_RESUME_PPI *S3Resume;
|
||||||
EFI_PHYSICAL_ADDRESS PageTables;
|
|
||||||
|
|
||||||
// PERF_START (PeiServices, L"DxeIpl", NULL, 0);
|
// PERF_START (PeiServices, L"DxeIpl", NULL, 0);
|
||||||
TopOfStack = 0;
|
|
||||||
BaseOfStack = 0;
|
|
||||||
BspStore = 0;
|
|
||||||
PageTables = 0;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// if in S3 Resume, restore configure
|
// if in S3 Resume, restore configure
|
||||||
@ -217,17 +205,6 @@ Returns:
|
|||||||
PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol ();
|
PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol ();
|
||||||
ASSERT (PeiEfiPeiPeCoffLoader != NULL);
|
ASSERT (PeiEfiPeiPeCoffLoader != NULL);
|
||||||
|
|
||||||
//
|
|
||||||
// Allocate 128KB for the Stack
|
|
||||||
//
|
|
||||||
PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack);
|
|
||||||
ASSERT (BaseOfStack != 0);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Add architecture-specifc HOBs (including the BspStore HOB)
|
|
||||||
//
|
|
||||||
Status = CreateArchSpecificHobs (&BspStore);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE type compressed Firmware Volume file
|
// Find the EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE type compressed Firmware Volume file
|
||||||
@ -290,44 +267,8 @@ Returns:
|
|||||||
EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT
|
EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "DXE Core Entry\n"));
|
if (FeaturePcdGet (PcdDxeIplBuildShareCodeHobs)) {
|
||||||
if (FeaturePcdGet(PcdDxeIplSwitchToLongMode)) {
|
if (FeaturePcdGet (PcdDxeIplSupportEfiDecompress)) {
|
||||||
//
|
|
||||||
// Compute the top of the stack we were allocated, which is used to load X64 dxe core.
|
|
||||||
// Pre-allocate a 32 bytes which confroms to x64 calling convention.
|
|
||||||
//
|
|
||||||
// The first four parameters to a function are passed in rcx, rdx, r8 and r9.
|
|
||||||
// Any further parameters are pushed on the stack. Furthermore, space (4 * 8bytes) for the
|
|
||||||
// register parameters is reserved on the stack, in case the called function
|
|
||||||
// wants to spill them; this is important if the function is variadic.
|
|
||||||
//
|
|
||||||
TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32;
|
|
||||||
|
|
||||||
//
|
|
||||||
// X64 Calling Conventions requires that the stack must be aligned to 16 bytes
|
|
||||||
//
|
|
||||||
TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, 16);
|
|
||||||
//
|
|
||||||
// Load the GDT of Go64. Since the GDT of 32-bit Tiano locates in the BS_DATA
|
|
||||||
// memory, it may be corrupted when copying FV to high-end memory
|
|
||||||
//
|
|
||||||
LoadGo64Gdt();
|
|
||||||
//
|
|
||||||
// Limit to 36 bits of addressing for debug. Should get it from CPU
|
|
||||||
//
|
|
||||||
PageTables = CreateIdentityMappingPageTables (36);
|
|
||||||
//
|
|
||||||
// Go to Long Mode. Interrupts will not get turned on until the CPU AP is loaded.
|
|
||||||
// Call x64 drivers passing in single argument, a pointer to the HOBs.
|
|
||||||
//
|
|
||||||
ActivateLongMode (
|
|
||||||
PageTables,
|
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)(HobList.Raw),
|
|
||||||
TopOfStack,
|
|
||||||
0x00000000,
|
|
||||||
DxeCoreEntryPoint
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
//
|
//
|
||||||
// Add HOB for the EFI Decompress Protocol
|
// Add HOB for the EFI Decompress Protocol
|
||||||
//
|
//
|
||||||
@ -336,7 +277,8 @@ Returns:
|
|||||||
(VOID *)&gEfiDecompress,
|
(VOID *)&gEfiDecompress,
|
||||||
sizeof (gEfiDecompress)
|
sizeof (gEfiDecompress)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if (FeaturePcdGet (PcdDxeIplSupportTianoDecompress)) {
|
||||||
//
|
//
|
||||||
// Add HOB for the Tiano Decompress Protocol
|
// Add HOB for the Tiano Decompress Protocol
|
||||||
//
|
//
|
||||||
@ -345,7 +287,8 @@ Returns:
|
|||||||
(VOID *)&gTianoDecompress,
|
(VOID *)&gTianoDecompress,
|
||||||
sizeof (gTianoDecompress)
|
sizeof (gTianoDecompress)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if (FeaturePcdGet (PcdDxeIplSupportCustomDecompress)) {
|
||||||
//
|
//
|
||||||
// Add HOB for the user customized Decompress Protocol
|
// Add HOB for the user customized Decompress Protocol
|
||||||
//
|
//
|
||||||
@ -354,6 +297,7 @@ Returns:
|
|||||||
(VOID *)&gCustomDecompress,
|
(VOID *)&gCustomDecompress,
|
||||||
sizeof (gCustomDecompress)
|
sizeof (gCustomDecompress)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add HOB for the PE/COFF Loader Protocol
|
// Add HOB for the PE/COFF Loader Protocol
|
||||||
@ -363,21 +307,10 @@ Returns:
|
|||||||
(VOID *)&PeiEfiPeiPeCoffLoader,
|
(VOID *)&PeiEfiPeiPeCoffLoader,
|
||||||
sizeof (VOID *)
|
sizeof (VOID *)
|
||||||
);
|
);
|
||||||
//
|
|
||||||
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
|
||||||
// for safety.
|
|
||||||
//
|
|
||||||
TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT;
|
|
||||||
TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
|
||||||
|
|
||||||
SwitchIplStacks (
|
|
||||||
(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
|
|
||||||
HobList.Raw,
|
|
||||||
NULL,
|
|
||||||
(VOID *) (UINTN) TopOfStack,
|
|
||||||
(VOID *) (UINTN) BspStore
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_INFO, "DXE Core Entry\n"));
|
||||||
|
HandOffToDxeCore (DxeCoreEntryPoint, HobList);
|
||||||
//
|
//
|
||||||
// If we get here, then the DXE Core returned. This is an error
|
// If we get here, then the DXE Core returned. This is an error
|
||||||
// Dxe Core should not return.
|
// Dxe Core should not return.
|
||||||
|
@ -21,66 +21,69 @@ Abstract:
|
|||||||
|
|
||||||
#include "DxeIpl.h"
|
#include "DxeIpl.h"
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
CreateArchSpecificHobs (
|
|
||||||
OUT EFI_PHYSICAL_ADDRESS *BspStore
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Creates architecture-specific HOBs.
|
|
||||||
|
|
||||||
Note: New parameters should NOT be added for any HOBs that are added to this
|
|
||||||
function. BspStore is a special case because it is required for the
|
|
||||||
call to SwitchStacks() in DxeLoad().
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
BspStore - The address of the BSP Store for those architectures that need
|
|
||||||
it. Otherwise 0.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - The HOBs were created successfully.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
*BspStore = 0;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Transfers control to a function starting with a new stack.
|
|
||||||
|
|
||||||
Transfers control to the function specified by EntryPoint using the new stack
|
|
||||||
specified by NewStack and passing in the parameters specified by Context1 and
|
|
||||||
Context2. Context1 and Context2 are optional and may be NULL. The function
|
|
||||||
EntryPoint must never return.
|
|
||||||
|
|
||||||
If EntryPoint is NULL, then ASSERT().
|
|
||||||
If NewStack is NULL, then ASSERT().
|
|
||||||
|
|
||||||
@param EntryPoint A pointer to function to call with the new stack.
|
|
||||||
@param Context1 A pointer to the context to pass into the EntryPoint
|
|
||||||
function.
|
|
||||||
@param Context2 A pointer to the context to pass into the EntryPoint
|
|
||||||
function.
|
|
||||||
@param NewStack A pointer to the new stack to use for the EntryPoint
|
|
||||||
function.
|
|
||||||
@param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
|
|
||||||
Reserved on other architectures.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
HandOffToDxeCore (
|
||||||
SwitchIplStacks (
|
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
|
||||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
IN EFI_PEI_HOB_POINTERS HobList
|
||||||
IN VOID *Context1, OPTIONAL
|
|
||||||
IN VOID *Context2, OPTIONAL
|
|
||||||
IN VOID *NewStack,
|
|
||||||
IN VOID *NewBsp
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
SwitchStack (EntryPoint, Context1, Context2, NewStack);
|
EFI_STATUS Status;
|
||||||
|
EFI_PHYSICAL_ADDRESS BaseOfStack;
|
||||||
|
EFI_PHYSICAL_ADDRESS TopOfStack;
|
||||||
|
EFI_PHYSICAL_ADDRESS PageTables;
|
||||||
|
|
||||||
|
Status = PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
if (FeaturePcdGet(PcdDxeIplSwitchToLongMode)) {
|
||||||
|
//
|
||||||
|
// Compute the top of the stack we were allocated, which is used to load X64 dxe core.
|
||||||
|
// Pre-allocate a 32 bytes which confroms to x64 calling convention.
|
||||||
|
//
|
||||||
|
// The first four parameters to a function are passed in rcx, rdx, r8 and r9.
|
||||||
|
// Any further parameters are pushed on the stack. Furthermore, space (4 * 8bytes) for the
|
||||||
|
// register parameters is reserved on the stack, in case the called function
|
||||||
|
// wants to spill them; this is important if the function is variadic.
|
||||||
|
//
|
||||||
|
TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32;
|
||||||
|
|
||||||
|
//
|
||||||
|
// X64 Calling Conventions requires that the stack must be aligned to 16 bytes
|
||||||
|
//
|
||||||
|
TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, 16);
|
||||||
|
//
|
||||||
|
// Load the GDT of Go64. Since the GDT of 32-bit Tiano locates in the BS_DATA
|
||||||
|
// memory, it may be corrupted when copying FV to high-end memory
|
||||||
|
//
|
||||||
|
LoadGo64Gdt();
|
||||||
|
//
|
||||||
|
// Limit to 36 bits of addressing for debug. Should get it from CPU
|
||||||
|
//
|
||||||
|
PageTables = CreateIdentityMappingPageTables (36);
|
||||||
|
//
|
||||||
|
// Go to Long Mode. Interrupts will not get turned on until the CPU AP is loaded.
|
||||||
|
// Call x64 drivers passing in single argument, a pointer to the HOBs.
|
||||||
|
//
|
||||||
|
ActivateLongMode (
|
||||||
|
PageTables,
|
||||||
|
(EFI_PHYSICAL_ADDRESS)(UINTN)(HobList.Raw),
|
||||||
|
TopOfStack,
|
||||||
|
0x00000000,
|
||||||
|
DxeCoreEntryPoint
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||||
|
// for safety.
|
||||||
|
//
|
||||||
|
TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT;
|
||||||
|
TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||||
|
|
||||||
|
SwitchStack (
|
||||||
|
(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
|
||||||
|
HobList.Raw,
|
||||||
|
NULL,
|
||||||
|
(VOID *) (UINTN) TopOfStack
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,91 +21,44 @@ Abstract:
|
|||||||
|
|
||||||
#include "DxeIpl.h"
|
#include "DxeIpl.h"
|
||||||
|
|
||||||
EFI_STATUS
|
VOID
|
||||||
CreateArchSpecificHobs (
|
HandOffToDxeCore (
|
||||||
OUT EFI_PHYSICAL_ADDRESS *BspStore
|
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
|
||||||
|
IN EFI_PEI_HOB_POINTERS HobList
|
||||||
)
|
)
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Creates architecture-specific HOBs.
|
|
||||||
|
|
||||||
Note: New parameters should NOT be added for any HOBs that are added to this
|
|
||||||
function. BspStore is a special case because it is required for the
|
|
||||||
call to SwitchStacks() in DxeLoad().
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
BspStore - The address of the BSP Store for those architectures that need
|
|
||||||
it. Otherwise 0.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - The HOBs were created successfully.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
VOID *BaseOfStack;
|
||||||
|
VOID *TopOfStack;
|
||||||
|
VOID *BspStore;
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
//
|
||||||
|
// Allocate 128KB for the Stack
|
||||||
ASSERT (NULL != BspStore);
|
//
|
||||||
|
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
|
||||||
|
ASSERT (BaseOfStack != NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate 16KB for the BspStore
|
// Allocate 16KB for the BspStore
|
||||||
//
|
//
|
||||||
Status = PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (BSP_STORE_SIZE), BspStore);
|
BspStore = AllocatePages (EFI_SIZE_TO_PAGES (BSP_STORE_SIZE));
|
||||||
if (EFI_ERROR (Status)) {
|
ASSERT (BspStore != NULL);
|
||||||
return Status;
|
//
|
||||||
}
|
// Build BspStoreHob
|
||||||
|
//
|
||||||
|
BuildBspStoreHob ((EFI_PHYSICAL_ADDRESS) (UINTN) BspStore, BSP_STORE_SIZE, EfiBootServicesData);
|
||||||
|
|
||||||
BuildBspStoreHob (
|
//
|
||||||
*BspStore,
|
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||||
BSP_STORE_SIZE,
|
// for safety.
|
||||||
EfiBootServicesData
|
//
|
||||||
);
|
TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||||
|
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Transfers control to a function starting with a new stack.
|
|
||||||
|
|
||||||
Transfers control to the function specified by EntryPoint using the new stack
|
|
||||||
specified by NewStack and passing in the parameters specified by Context1 and
|
|
||||||
Context2. Context1 and Context2 are optional and may be NULL. The function
|
|
||||||
EntryPoint must never return.
|
|
||||||
|
|
||||||
If EntryPoint is NULL, then ASSERT().
|
|
||||||
If NewStack is NULL, then ASSERT().
|
|
||||||
|
|
||||||
@param EntryPoint A pointer to function to call with the new stack.
|
|
||||||
@param Context1 A pointer to the context to pass into the EntryPoint
|
|
||||||
function.
|
|
||||||
@param Context2 A pointer to the context to pass into the EntryPoint
|
|
||||||
function.
|
|
||||||
@param NewStack A pointer to the new stack to use for the EntryPoint
|
|
||||||
function.
|
|
||||||
@param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
|
|
||||||
Reserved on other architectures.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
SwitchIplStacks (
|
|
||||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
|
||||||
IN VOID *Context1, OPTIONAL
|
|
||||||
IN VOID *Context2, OPTIONAL
|
|
||||||
IN VOID *NewStack,
|
|
||||||
IN VOID *NewBsp
|
|
||||||
)
|
|
||||||
{
|
|
||||||
AsmSwitchStackAndBackingStore (
|
AsmSwitchStackAndBackingStore (
|
||||||
EntryPoint,
|
(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
|
||||||
Context1,
|
HobList.Raw,
|
||||||
Context2,
|
NULL,
|
||||||
NewStack,
|
TopOfStack,
|
||||||
NewBsp
|
BspStore
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
52
EdkModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c
Normal file
52
EdkModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2006, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
Module Name:
|
||||||
|
|
||||||
|
DxeLoadFunc.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
Ia32-specifc functionality for DxeLoad.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
#include "DxeIpl.h"
|
||||||
|
|
||||||
|
VOID
|
||||||
|
HandOffToDxeCore (
|
||||||
|
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
|
||||||
|
IN EFI_PEI_HOB_POINTERS HobList
|
||||||
|
)
|
||||||
|
{
|
||||||
|
VOID *BaseOfStack;
|
||||||
|
VOID *TopOfStack;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Allocate 128KB for the Stack
|
||||||
|
//
|
||||||
|
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
|
||||||
|
ASSERT (BaseOfStack != NULL);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||||
|
// for safety.
|
||||||
|
//
|
||||||
|
TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||||
|
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||||
|
|
||||||
|
SwitchStack (
|
||||||
|
(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
|
||||||
|
HobList.Raw,
|
||||||
|
NULL,
|
||||||
|
TopOfStack
|
||||||
|
);
|
||||||
|
}
|
@ -1018,6 +1018,14 @@
|
|||||||
<MaxDatumSize>1</MaxDatumSize>
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
<Value>TRUE</Value>
|
<Value>TRUE</Value>
|
||||||
</PcdData>
|
</PcdData>
|
||||||
|
<PcdData ItemType="FEATURE_FLAG">
|
||||||
|
<C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>
|
||||||
|
<Token>0x0001003c</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>BOOLEAN</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>TRUE</Value>
|
||||||
|
</PcdData>
|
||||||
</PcdBuildDefinition>
|
</PcdBuildDefinition>
|
||||||
<ModuleSaBuildOptions>
|
<ModuleSaBuildOptions>
|
||||||
<FvBinding>NULL</FvBinding>
|
<FvBinding>NULL</FvBinding>
|
||||||
@ -6684,6 +6692,14 @@
|
|||||||
<MaxDatumSize>1</MaxDatumSize>
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
<Value>TRUE</Value>
|
<Value>TRUE</Value>
|
||||||
</PcdData>
|
</PcdData>
|
||||||
|
<PcdData ItemType="FEATURE_FLAG">
|
||||||
|
<C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>
|
||||||
|
<Token>0x0001003c</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>BOOLEAN</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>TRUE</Value>
|
||||||
|
</PcdData>
|
||||||
</PcdBuildDefinition>
|
</PcdBuildDefinition>
|
||||||
<ModuleSaBuildOptions>
|
<ModuleSaBuildOptions>
|
||||||
<FvBinding>NULL</FvBinding>
|
<FvBinding>NULL</FvBinding>
|
||||||
@ -11131,6 +11147,14 @@
|
|||||||
<MaxDatumSize>1</MaxDatumSize>
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
<Value>TRUE</Value>
|
<Value>TRUE</Value>
|
||||||
</PcdData>
|
</PcdData>
|
||||||
|
<PcdData ItemType="FEATURE_FLAG">
|
||||||
|
<C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>
|
||||||
|
<Token>0x0001003c</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>BOOLEAN</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>TRUE</Value>
|
||||||
|
</PcdData>
|
||||||
</PcdBuildDefinition>
|
</PcdBuildDefinition>
|
||||||
<ModuleSaBuildOptions>
|
<ModuleSaBuildOptions>
|
||||||
<FvBinding>NULL</FvBinding>
|
<FvBinding>NULL</FvBinding>
|
||||||
@ -15582,6 +15606,14 @@
|
|||||||
<MaxDatumSize>1</MaxDatumSize>
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
<Value>TRUE</Value>
|
<Value>TRUE</Value>
|
||||||
</PcdData>
|
</PcdData>
|
||||||
|
<PcdData ItemType="FEATURE_FLAG">
|
||||||
|
<C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>
|
||||||
|
<Token>0x0001003c</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>BOOLEAN</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>TRUE</Value>
|
||||||
|
</PcdData>
|
||||||
</PcdBuildDefinition>
|
</PcdBuildDefinition>
|
||||||
<ModuleSaBuildOptions>
|
<ModuleSaBuildOptions>
|
||||||
<FvBinding>NULL</FvBinding>
|
<FvBinding>NULL</FvBinding>
|
||||||
|
@ -1247,14 +1247,23 @@
|
|||||||
<DefaultValue>FALSE</DefaultValue>
|
<DefaultValue>FALSE</DefaultValue>
|
||||||
<HelpText>Whether VGA decoding is enabled on this platform so we should avoid those aliased resources</HelpText>
|
<HelpText>Whether VGA decoding is enabled on this platform so we should avoid those aliased resources</HelpText>
|
||||||
</PcdEntry>
|
</PcdEntry>
|
||||||
<PcdEntry>
|
<PcdEntry SupArchList="IA32">
|
||||||
<C_Name>PcdDxeIplSwitchToLongMode</C_Name>
|
<C_Name>PcdDxeIplSwitchToLongMode</C_Name>
|
||||||
<Token>0x0001003b</Token>
|
<Token>0x0001003b</Token>
|
||||||
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
<DatumType>BOOLEAN</DatumType>
|
<DatumType>BOOLEAN</DatumType>
|
||||||
<ValidUsage>FEATURE_FLAG</ValidUsage>
|
<ValidUsage>FEATURE_FLAG</ValidUsage>
|
||||||
<DefaultValue>FALSE</DefaultValue>
|
<DefaultValue>TRUE</DefaultValue>
|
||||||
<HelpText>If this feature is enabled, then the DXE IPL will load a 64-bit DxeCore.</HelpText>
|
<HelpText>If this feature is enabled, then the DXE IPL will load a 64-bit DxeCore.</HelpText>
|
||||||
</PcdEntry>
|
</PcdEntry>
|
||||||
|
<PcdEntry>
|
||||||
|
<C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>
|
||||||
|
<Token>0x0001003c</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>BOOLEAN</DatumType>
|
||||||
|
<ValidUsage>FEATURE_FLAG</ValidUsage>
|
||||||
|
<DefaultValue>FALSE</DefaultValue>
|
||||||
|
<HelpText>If this feature is enabled, DXE IPL will build a series of HOBs to share code with DXE Core.</HelpText>
|
||||||
|
</PcdEntry>
|
||||||
</PcdDeclarations>
|
</PcdDeclarations>
|
||||||
</PackageSurfaceArea>
|
</PackageSurfaceArea>
|
Loading…
x
Reference in New Issue
Block a user