[edk2-devel] [PATCH 4/6] UefiCpuPkg/ResetVector: Add ReloadFlat32 in UefiCpuPkg

Min Xu min.m.xu at intel.com
Mon Jul 12 01:19:40 UTC 2021


RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429

Load the GDT and set the default CR0, then jump to Flat 32 protected mode.

Cc: Eric Dong <eric.dong at intel.com>
Cc: Jiewen Yao <jiewen.yao at intel.com>
Cc: Ray Ni <ray.ni at intel.com>
Cc: Laszlo Ersek <lersek at redhat.com>
Signed-off-by: Min Xu <min.m.xu at intel.com>
---
 .../ResetVector/Vtf0/Ia32/ReloadFlat32.asm    | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm

diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm
new file mode 100644
index 000000000000..e8a4c47762df
--- /dev/null
+++ b/UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm
@@ -0,0 +1,43 @@
+;------------------------------------------------------------------------------
+; @file
+;   Load the GDT and set the CR0, then jump to Flat 32 protected mode.
+;
+; Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;------------------------------------------------------------------------------
+
+%define SEC_DEFAULT_CR0  0x00000023
+%define SEC_DEFAULT_CR4  0x640
+
+BITS    32
+
+;
+; Modified:  EAX, EBX, CR0, CR4, DS, ES, FS, GS, SS
+;
+ReloadFlat32:
+
+    cli
+    mov     ebx, ADDR_OF(gdtr)
+    lgdt    [ebx]
+
+    mov     eax, SEC_DEFAULT_CR0
+    mov     cr0, eax
+
+    jmp     LINEAR_CODE_SEL:dword ADDR_OF(jumpToFlat32BitAndLandHere)
+BITS    32
+jumpToFlat32BitAndLandHere:
+
+    mov     eax, SEC_DEFAULT_CR4
+    mov     cr4, eax
+
+    debugShowPostCode POSTCODE_32BIT_MODE
+
+    mov     ax, LINEAR_SEL
+    mov     ds, ax
+    mov     es, ax
+    mov     fs, ax
+    mov     gs, ax
+    mov     ss, ax
+
+    OneTimeCallRet ReloadFlat32
-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#77679): https://edk2.groups.io/g/devel/message/77679
Mute This Topic: https://groups.io/mt/84144141/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list