X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FCore%2FDxeIplPeim%2FIa32%2FDxeLoadFunc.c;h=1bbd839e19c1930e42b4ee9fc7648efa347fa5d9;hp=6b61086cf2d86397152f039f1f2de593b8a45f21;hb=f40793becf28ffb9b58e29c8501410247df9dedd;hpb=16fdd1e20e44833524c31c863a2bd6ea93e8fedb diff --git a/EdkModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c b/EdkModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c index 6b61086cf2..1bbd839e19 100644 --- a/EdkModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c +++ b/EdkModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c @@ -20,6 +20,31 @@ Abstract: --*/ #include "DxeIpl.h" +#include "VirtualMemory.h" + +// +// Global Descriptor Table (GDT) +// +GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT gGdtEntries [] = { +/* selector { Global Segment Descriptor } */ +/* 0x00 */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //null descriptor +/* 0x08 */ {0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}, //linear data segment descriptor +/* 0x10 */ {0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}, //linear code segment descriptor +/* 0x18 */ {0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}, //system data segment descriptor +/* 0x20 */ {0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}, //system code segment descriptor +/* 0x28 */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //spare segment descriptor +/* 0x30 */ {0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}, //system data segment descriptor +/* 0x38 */ {0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 1, 0, 1, 0}, //system code segment descriptor +/* 0x40 */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //spare segment descriptor +}; + +// +// IA32 Gdt register +// +GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR gGdt = { + sizeof (gGdtEntries) - 1, + (UINTN) gGdtEntries + }; VOID HandOffToDxeCore ( @@ -30,7 +55,7 @@ HandOffToDxeCore ( EFI_STATUS Status; EFI_PHYSICAL_ADDRESS BaseOfStack; EFI_PHYSICAL_ADDRESS TopOfStack; - EFI_PHYSICAL_ADDRESS PageTables; + UINTN PageTables; Status = PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack); ASSERT_EFI_ERROR (Status); @@ -51,25 +76,27 @@ HandOffToDxeCore ( // 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(); + AsmWriteGdtr (&gGdt); // - // Limit to 36 bits of addressing for debug. Should get it from CPU - // - PageTables = CreateIdentityMappingPageTables (36); + // Create page table and save PageMapLevel4 to CR3 // + PageTables = CreateIdentityMappingPageTables (); + AsmWriteCr3 (PageTables); + // // 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 + // + AsmEnablePaging64 ( + SYS_CODE64_SEL, + DxeCoreEntryPoint, + (EFI_PHYSICAL_ADDRESS)(UINTN)(HobList.Raw), + 0, + TopOfStack ); } else { // @@ -87,3 +114,4 @@ HandOffToDxeCore ( ); } } +