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 - 2016, Intel Corporation. All rights reserved.<BR>
6 ; This program and the accompanying materials
7 ; are licensed and made available under the terms and conditions of the BSD License
8 ; which accompanies this distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php.
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 ; Define assembler characteristics
19 extern ASM_PFX(TempRamInitApi)
25 movd esi, mm7 ; restore ESP from MM7
31 ; Perform early platform initialization
33 global ASM_PFX(SecPlatformInit)
34 ASM_PFX(SecPlatformInit):
39 ; Protected mode portion initializes stack, configures cache, and calls C entry point
42 ;----------------------------------------------------------------------------
44 ; Procedure: ProtectedModeEntryPoint
46 ; Input: Executing in 32 Bit Protected (flat) mode
54 ; Output: This function never returns
63 ; Perform any essential early platform initilaisation
66 ;----------------------------------------------------------------------------
67 global ASM_PFX(ProtectedModeEntryPoint)
68 ASM_PFX(ProtectedModeEntryPoint):
70 ; Dummy function. Consume 2 API to make sure they can be linked.
72 mov eax, ASM_PFX(TempRamInitApi)
78 ; ROM-based Global-Descriptor Table for the PEI Phase
81 global ASM_PFX(BootGdtTable)
84 ; GDT[0]: 0x00: Null entry, never used.
86 NULL_SEL equ $ - GDT_BASE ; Selector [0]
88 ASM_PFX(BootGdtTable): DD 0
91 ; Linear code segment descriptor
93 LINEAR_CODE_SEL equ $ - GDT_BASE ; Selector [0x8]
94 DW 0FFFFh ; limit 0xFFFF
97 DB 09Bh ; present, ring 0, data, expand-up, not-writable
98 DB 0CFh ; page-granular, 32-bit
101 ; System data segment descriptor
103 SYS_DATA_SEL equ $ - GDT_BASE ; Selector [0x10]
104 DW 0FFFFh ; limit 0xFFFF
107 DB 093h ; present, ring 0, data, expand-up, not-writable
108 DB 0CFh ; page-granular, 32-bit
111 GDT_SIZE EQU $ - GDT_BASE ; Size, in bytes
116 GdtDesc: ; GDT descriptor
117 DW GDT_SIZE - 1 ; GDT limit
118 DD GDT_BASE ; GDT base address
120 global ASM_PFX(ProtectedModeEntryLinearAddress)
121 global ASM_PFX(ProtectedModeEntryLinearOffset)
123 ASM_PFX(ProtectedModeEntryLinearAddress):
124 ASM_PFX(ProtectedModeEntryLinearOffset):
125 DD ASM_PFX(ProtectedModeEntryPoint) ; Offset of our 32 bit code