]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/Ia32/Flat32.asm
IntelFsp2Pkg SecFspSecPlatformLibNull: Convert Ia32/SecCarInit.asm to NASM
[mirror_edk2.git] / IntelFsp2Pkg / Library / SecFspSecPlatformLibNull / Ia32 / Flat32.asm
CommitLineData
cf1d4549
JY
1;; @file\r
2; This is the code that goes from real-mode to protected mode.\r
3; It consumes the reset vector, configures the stack.\r
4;\r
5; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
6; This program and the accompanying materials\r
7; are licensed and made available under the terms and conditions of the BSD License\r
8; which accompanies this distribution. The full text of the license may be found at\r
9; http://opensource.org/licenses/bsd-license.php.\r
10;\r
11; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13;;\r
14\r
15;\r
16; Define assembler characteristics\r
17;\r
18.586p\r
19.xmm\r
20.model flat, c\r
21\r
22EXTRN TempRamInitApi:NEAR\r
23\r
24.code \r
25\r
26RET_ESI MACRO\r
27\r
28 movd esi, mm7 ; restore ESP from MM7\r
29 jmp esi\r
30\r
31ENDM\r
32\r
33;\r
34; Perform early platform initialization\r
35;\r
36SecPlatformInit PROC NEAR PUBLIC\r
37\r
38 RET_ESI\r
39\r
40SecPlatformInit ENDP\r
41\r
42;\r
43; Protected mode portion initializes stack, configures cache, and calls C entry point\r
44;\r
45\r
46;----------------------------------------------------------------------------\r
47;\r
48; Procedure: ProtectedModeEntryPoint\r
49;\r
50; Input: Executing in 32 Bit Protected (flat) mode\r
51; cs: 0-4GB\r
52; ds: 0-4GB\r
53; es: 0-4GB\r
54; fs: 0-4GB\r
55; gs: 0-4GB\r
56; ss: 0-4GB\r
57;\r
58; Output: This function never returns\r
59;\r
60; Destroys:\r
61; ecx\r
62; edi\r
63; esi\r
64; esp\r
65;\r
66; Description:\r
67; Perform any essential early platform initilaisation\r
68; Setup a stack\r
69;\r
70;----------------------------------------------------------------------------\r
71\r
72ProtectedModeEntryPoint PROC NEAR C PUBLIC\r
73 ;\r
74 ; Dummy function. Consume 2 API to make sure they can be linked.\r
75 ;\r
76 mov eax, TempRamInitApi\r
77\r
78 ; Should never return\r
79 jmp $\r
80\r
81ProtectedModeEntryPoint ENDP\r
82\r
83;\r
84; ROM-based Global-Descriptor Table for the PEI Phase\r
85;\r
86align 16\r
87PUBLIC BootGdtTable\r
88\r
89;\r
90; GDT[0]: 0x00: Null entry, never used.\r
91;\r
92NULL_SEL equ $ - GDT_BASE ; Selector [0]\r
93GDT_BASE:\r
94BootGdtTable DD 0\r
95 DD 0\r
96;\r
97; Linear code segment descriptor\r
98;\r
99LINEAR_CODE_SEL equ $ - GDT_BASE ; Selector [0x8]\r
100 DW 0FFFFh ; limit 0xFFFF\r
101 DW 0 ; base 0\r
102 DB 0\r
103 DB 09Bh ; present, ring 0, data, expand-up, not-writable\r
104 DB 0CFh ; page-granular, 32-bit\r
105 DB 0\r
106;\r
107; System data segment descriptor\r
108;\r
109SYS_DATA_SEL equ $ - GDT_BASE ; Selector [0x10]\r
110 DW 0FFFFh ; limit 0xFFFF\r
111 DW 0 ; base 0\r
112 DB 0\r
113 DB 093h ; present, ring 0, data, expand-up, not-writable\r
114 DB 0CFh ; page-granular, 32-bit\r
115 DB 0\r
116\r
117GDT_SIZE EQU $ - BootGDTtable ; Size, in bytes\r
118\r
119;\r
120; GDT Descriptor\r
121;\r
122GdtDesc: ; GDT descriptor\r
123 DW GDT_SIZE - 1 ; GDT limit\r
124 DD OFFSET BootGdtTable ; GDT base address\r
125\r
126ProtectedModeEntryLinearAddress LABEL FWORD\r
127ProtectedModeEntryLinearOffset LABEL DWORD\r
128 DD OFFSET ProtectedModeEntryPoint ; Offset of our 32 bit code\r
129 DW LINEAR_CODE_SEL\r
130 \r
131END\r