From 4fd3b50ca609f108a53558bee105c7410c0fa461 Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Wed, 17 Nov 2021 14:45:06 +0800 Subject: [PATCH] modify the assemble code Signed-off-by: Dun Tan --- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 2 +- MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm | 3 +++ MdePkg/Library/BaseLib/Ia32/WriteIdtr.nasm | 3 +++ MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf | 1 + MdePkg/Library/BaseLib/X86EnablePaging64.c | 5 ++++- MdePkg/Library/BaseLib/X86WriteIdtr.c | 4 +++- UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c | 3 ++- UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 4 +++- 8 files changed, 20 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 659283824634..3902d3aeea51 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -234,7 +234,7 @@ DxeMain ( IN VOID *HobStart ) { - IoWrite8(0x3f8, 'a'); + IoWrite8(0x3f8, 'f'); EFI_STATUS Status; EFI_PHYSICAL_ADDRESS MemoryBaseAddress; UINT64 MemoryLength; diff --git a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm index 544e3c389246..ea287fc6b77d 100644 --- a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm +++ b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm @@ -30,6 +30,9 @@ ;------------------------------------------------------------------------------ global ASM_PFX(InternalX86EnablePaging64) ASM_PFX(InternalX86EnablePaging64): + mov dx, 0x3f8 + mov al, 't' + out dx, al cli mov DWORD [esp], .0 ; offset for far retf, seg is the 1st arg mov eax, cr4 diff --git a/MdePkg/Library/BaseLib/Ia32/WriteIdtr.nasm b/MdePkg/Library/BaseLib/Ia32/WriteIdtr.nasm index 074dc1846011..09ad9b65c3cf 100644 --- a/MdePkg/Library/BaseLib/Ia32/WriteIdtr.nasm +++ b/MdePkg/Library/BaseLib/Ia32/WriteIdtr.nasm @@ -26,6 +26,9 @@ ;------------------------------------------------------------------------------ global ASM_PFX(InternalX86WriteIdtr) ASM_PFX(InternalX86WriteIdtr): + mov dx, 0x3f8 + mov al, 't' + out dx, al mov eax, [esp + 4] pushfd cli diff --git a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf index d09bd12bef19..4d78e64fa286 100644 --- a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf +++ b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf @@ -240,6 +240,7 @@ PcdLib DebugLib BaseMemoryLib + IoLib [Pcd] gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength ## SOMETIMES_CONSUMES diff --git a/MdePkg/Library/BaseLib/X86EnablePaging64.c b/MdePkg/Library/BaseLib/X86EnablePaging64.c index 1323e68de5fc..ef268f82be76 100644 --- a/MdePkg/Library/BaseLib/X86EnablePaging64.c +++ b/MdePkg/Library/BaseLib/X86EnablePaging64.c @@ -8,9 +8,10 @@ - +#include #include "BaseLibInternals.h" + /** Enables the 64-bit paging mode on the CPU. @@ -53,7 +54,9 @@ AsmEnablePaging64 ( IN UINT64 NewStack ) { + IoWrite8(0x3f8, '9'); ASSERT (EntryPoint != 0); ASSERT (NewStack != 0); + IoWrite8(0x3f8, '8'); InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); } diff --git a/MdePkg/Library/BaseLib/X86WriteIdtr.c b/MdePkg/Library/BaseLib/X86WriteIdtr.c index 9ea979b76d94..b66d601212be 100644 --- a/MdePkg/Library/BaseLib/X86WriteIdtr.c +++ b/MdePkg/Library/BaseLib/X86WriteIdtr.c @@ -8,7 +8,7 @@ - +#include #include "BaseLibInternals.h" /** @@ -28,6 +28,8 @@ AsmWriteIdtr ( IN CONST IA32_DESCRIPTOR *Idtr ) { + IoWrite8(0x3f8, 'z'); ASSERT (Idtr != NULL); + IoWrite8(0x3f8, 'z'); InternalX86WriteIdtr (Idtr); } diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c index 186b50a9ed68..4fab1c4a7202 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c +++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c @@ -345,7 +345,7 @@ HandOffToDxeCore ( DEBUG (( DEBUG_INFO, - "%a() Stack Base: 0x%lx, Stack Size: 0x%x\n", + "%a() Stack Base: 0x%lx, oooooStack Size: 0x%x\n", __FUNCTION__, BaseOfStack, STACK_SIZE @@ -356,6 +356,7 @@ HandOffToDxeCore ( // Interrupts will not get turned on until the CPU AP is loaded. // Call x64 drivers passing in single argument, a pointer to the HOBs. // + DEBUG ((DEBUG_INFO, "the AsmEnablePaging64 addr is %p\n", AsmEnablePaging64)); AsmEnablePaging64 ( SYS_CODE64_SEL, DxeCoreEntryPoint, diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c index 98995c80c6f9..3ee5af36722d 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c @@ -400,6 +400,8 @@ _ModuleEntryPoint ( // Call constructor for all libraries ProcessLibraryConstructorList (); + DEBUG ((DEBUG_INFO, "the entrypoint addr is %p\n", _ModuleEntryPoint)); + DEBUG ((DEBUG_INFO, "the ProcessLibraryConstructorList addr is %p\n", ProcessLibraryConstructorList)); DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n")); DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof(UINTN))); @@ -412,7 +414,7 @@ _ModuleEntryPoint ( // Initialize floating point operating environment to be compliant with UEFI spec. InitializeFloatingPointUnits (); - + DEBUG ((DEBUG_INFO, "the InitializeFloatingPointUnits addr is %p\n", InitializeFloatingPointUnits)); // Build HOB based on information from Bootloader Status = BuildHobs (BootloaderParameter, &DxeFv); ASSERT_EFI_ERROR (Status);