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
22 EXTRN TempRamInitApi:NEAR
28 movd esi, mm7 ; restore ESP from MM7
34 ; Perform early platform initialization
36 SecPlatformInit PROC NEAR PUBLIC
43 ; Protected mode portion initializes stack, configures cache, and calls C entry point
46 ;----------------------------------------------------------------------------
48 ; Procedure: ProtectedModeEntryPoint
50 ; Input: Executing in 32 Bit Protected (flat) mode
58 ; Output: This function never returns
67 ; Perform any essential early platform initilaisation
70 ;----------------------------------------------------------------------------
72 ProtectedModeEntryPoint PROC NEAR C PUBLIC
74 ; Dummy function. Consume 2 API to make sure they can be linked.
76 mov eax, TempRamInitApi
81 ProtectedModeEntryPoint ENDP
84 ; ROM-based Global-Descriptor Table for the PEI Phase
90 ; GDT[0]: 0x00: Null entry, never used.
92 NULL_SEL equ $ - GDT_BASE ; Selector [0]
97 ; Linear code segment descriptor
99 LINEAR_CODE_SEL equ $ - GDT_BASE ; Selector [0x8]
100 DW 0FFFFh ; limit 0xFFFF
103 DB 09Bh ; present, ring 0, data, expand-up, not-writable
104 DB 0CFh ; page-granular, 32-bit
107 ; System data segment descriptor
109 SYS_DATA_SEL equ $ - GDT_BASE ; Selector [0x10]
110 DW 0FFFFh ; limit 0xFFFF
113 DB 093h ; present, ring 0, data, expand-up, not-writable
114 DB 0CFh ; page-granular, 32-bit
117 GDT_SIZE EQU $ - BootGDTtable ; Size, in bytes
122 GdtDesc: ; GDT descriptor
123 DW GDT_SIZE - 1 ; GDT limit
124 DD OFFSET BootGdtTable ; GDT base address
126 ProtectedModeEntryLinearAddress LABEL FWORD
127 ProtectedModeEntryLinearOffset LABEL DWORD
128 DD OFFSET ProtectedModeEntryPoint ; Offset of our 32 bit code