]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.asm
Add IntelFsp2Pkg and IntelFsp2WrapperPkg.
[mirror_edk2.git] / IntelFsp2Pkg / Library / SecFspSecPlatformLibNull / Ia32 / Flat32.asm
1 ;; @file
2 ; This is the code that goes from real-mode to protected mode.
3 ; It consumes the reset vector, configures the stack.
4 ;
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.
10 ;
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.
13 ;;
14
15 ;
16 ; Define assembler characteristics
17 ;
18 .586p
19 .xmm
20 .model flat, c
21
22 EXTRN TempRamInitApi:NEAR
23
24 .code
25
26 RET_ESI MACRO
27
28 movd esi, mm7 ; restore ESP from MM7
29 jmp esi
30
31 ENDM
32
33 ;
34 ; Perform early platform initialization
35 ;
36 SecPlatformInit PROC NEAR PUBLIC
37
38 RET_ESI
39
40 SecPlatformInit ENDP
41
42 ;
43 ; Protected mode portion initializes stack, configures cache, and calls C entry point
44 ;
45
46 ;----------------------------------------------------------------------------
47 ;
48 ; Procedure: ProtectedModeEntryPoint
49 ;
50 ; Input: Executing in 32 Bit Protected (flat) mode
51 ; cs: 0-4GB
52 ; ds: 0-4GB
53 ; es: 0-4GB
54 ; fs: 0-4GB
55 ; gs: 0-4GB
56 ; ss: 0-4GB
57 ;
58 ; Output: This function never returns
59 ;
60 ; Destroys:
61 ; ecx
62 ; edi
63 ; esi
64 ; esp
65 ;
66 ; Description:
67 ; Perform any essential early platform initilaisation
68 ; Setup a stack
69 ;
70 ;----------------------------------------------------------------------------
71
72 ProtectedModeEntryPoint PROC NEAR C PUBLIC
73 ;
74 ; Dummy function. Consume 2 API to make sure they can be linked.
75 ;
76 mov eax, TempRamInitApi
77
78 ; Should never return
79 jmp $
80
81 ProtectedModeEntryPoint ENDP
82
83 ;
84 ; ROM-based Global-Descriptor Table for the PEI Phase
85 ;
86 align 16
87 PUBLIC BootGdtTable
88
89 ;
90 ; GDT[0]: 0x00: Null entry, never used.
91 ;
92 NULL_SEL equ $ - GDT_BASE ; Selector [0]
93 GDT_BASE:
94 BootGdtTable DD 0
95 DD 0
96 ;
97 ; Linear code segment descriptor
98 ;
99 LINEAR_CODE_SEL equ $ - GDT_BASE ; Selector [0x8]
100 DW 0FFFFh ; limit 0xFFFF
101 DW 0 ; base 0
102 DB 0
103 DB 09Bh ; present, ring 0, data, expand-up, not-writable
104 DB 0CFh ; page-granular, 32-bit
105 DB 0
106 ;
107 ; System data segment descriptor
108 ;
109 SYS_DATA_SEL equ $ - GDT_BASE ; Selector [0x10]
110 DW 0FFFFh ; limit 0xFFFF
111 DW 0 ; base 0
112 DB 0
113 DB 093h ; present, ring 0, data, expand-up, not-writable
114 DB 0CFh ; page-granular, 32-bit
115 DB 0
116
117 GDT_SIZE EQU $ - BootGDTtable ; Size, in bytes
118
119 ;
120 ; GDT Descriptor
121 ;
122 GdtDesc: ; GDT descriptor
123 DW GDT_SIZE - 1 ; GDT limit
124 DD OFFSET BootGdtTable ; GDT base address
125
126 ProtectedModeEntryLinearAddress LABEL FWORD
127 ProtectedModeEntryLinearOffset LABEL DWORD
128 DD OFFSET ProtectedModeEntryPoint ; Offset of our 32 bit code
129 DW LINEAR_CODE_SEL
130
131 END