2 ; This is the code that goes from real-mode to protected mode.
3 ; It consumes the reset vector, configures the stack.
5 ; Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
6 ; SPDX-License-Identifier: BSD-2-Clause-Patent
10 ; Define assembler characteristics
13 extern ASM_PFX(TempRamInitApi)
19 movd esi, mm7 ; restore ESP from MM7
25 ; Perform early platform initialization
27 global ASM_PFX(SecPlatformInit)
28 ASM_PFX(SecPlatformInit):
33 ; Protected mode portion initializes stack, configures cache, and calls C entry point
36 ;----------------------------------------------------------------------------
38 ; Procedure: ProtectedModeEntryPoint
40 ; Input: Executing in 32 Bit Protected (flat) mode
48 ; Output: This function never returns
57 ; Perform any essential early platform initilaisation
60 ;----------------------------------------------------------------------------
61 global ASM_PFX(ProtectedModeEntryPoint)
62 ASM_PFX(ProtectedModeEntryPoint):
64 ; Dummy function. Consume 2 API to make sure they can be linked.
66 mov eax, ASM_PFX(TempRamInitApi)
72 ; ROM-based Global-Descriptor Table for the PEI Phase
75 global ASM_PFX(BootGdtTable)
78 ; GDT[0]: 0x00: Null entry, never used.
80 NULL_SEL equ $ - GDT_BASE ; Selector [0]
82 ASM_PFX(BootGdtTable): DD 0
85 ; Linear code segment descriptor
87 LINEAR_CODE_SEL equ $ - GDT_BASE ; Selector [0x8]
88 DW 0FFFFh ; limit 0xFFFF
91 DB 09Bh ; present, ring 0, data, expand-up, not-writable
92 DB 0CFh ; page-granular, 32-bit
95 ; System data segment descriptor
97 SYS_DATA_SEL equ $ - GDT_BASE ; Selector [0x10]
98 DW 0FFFFh ; limit 0xFFFF
101 DB 093h ; present, ring 0, data, expand-up, not-writable
102 DB 0CFh ; page-granular, 32-bit
105 GDT_SIZE EQU $ - GDT_BASE ; Size, in bytes
110 GdtDesc: ; GDT descriptor
111 DW GDT_SIZE - 1 ; GDT limit
112 DD GDT_BASE ; GDT base address
114 global ASM_PFX(ProtectedModeEntryLinearAddress)
115 global ASM_PFX(ProtectedModeEntryLinearOffset)
117 ASM_PFX(ProtectedModeEntryLinearAddress):
118 ASM_PFX(ProtectedModeEntryLinearOffset):
119 DD ASM_PFX(ProtectedModeEntryPoint) ; Offset of our 32 bit code