]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm
IntelFsp2Pkg: Add missing OEM status code defines.
[mirror_edk2.git] / IntelFsp2Pkg / FspSecCore / Ia32 / FspApiEntryM.nasm
CommitLineData
cf1d4549
JY
1;; @file\r
2; Provide FSP API entry points.\r
3;\r
4; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5; This program and the accompanying materials\r
6; are licensed and made available under the terms and conditions of the BSD License\r
7; which accompanies this distribution. The full text of the license may be found at\r
8; http://opensource.org/licenses/bsd-license.php.\r
9;\r
10; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12;;\r
13\r
14 SECTION .text\r
15\r
16;\r
17; Following are fixed PCDs\r
18;\r
19extern ASM_PFX(PcdGet32(PcdTemporaryRamBase))\r
20extern ASM_PFX(PcdGet32(PcdTemporaryRamSize))\r
21extern ASM_PFX(PcdGet32(PcdFspTemporaryRamSize))\r
22\r
23struc FSPM_UPD_COMMON\r
24 ; FSP_UPD_HEADER {\r
25 .FspUpdHeader: resd 8\r
26 ; }\r
27 ; FSPM_ARCH_UPD {\r
28 .Revision: resb 1\r
29 .Reserved: resb 3\r
30 .NvsBufferPtr: resd 1\r
31 .StackBase: resd 1\r
32 .StackSize: resd 1\r
33 .BootLoaderTolumSize: resd 1\r
34 .BootMode: resd 1\r
35 .Reserved1: resb 8\r
36 ; }\r
37 .size:\r
38endstruc\r
39\r
40;\r
41; Following functions will be provided in C\r
42;\r
43extern ASM_PFX(SecStartup)\r
44extern ASM_PFX(FspApiCommon)\r
45\r
46;\r
47; Following functions will be provided in PlatformSecLib\r
48;\r
49extern ASM_PFX(AsmGetFspBaseAddress)\r
50extern ASM_PFX(AsmGetFspInfoHeader)\r
51\r
52API_PARAM1_OFFSET EQU 34h ; ApiParam1 [ sub esp,8 + pushad + pushfd + push eax + call]\r
53FSP_HEADER_IMGBASE_OFFSET EQU 1Ch\r
54FSP_HEADER_CFGREG_OFFSET EQU 24h\r
55\r
56;----------------------------------------------------------------------------\r
57; FspMemoryInit API\r
58;\r
59; This FSP API is called after TempRamInit and initializes the memory.\r
60;\r
61;----------------------------------------------------------------------------\r
62global ASM_PFX(FspMemoryInitApi)\r
63ASM_PFX(FspMemoryInitApi):\r
64 mov eax, 3 ; FSP_API_INDEX.FspMemoryInitApiIndex\r
65 jmp ASM_PFX(FspApiCommon)\r
66\r
67;----------------------------------------------------------------------------\r
68; TempRamExitApi API\r
69;\r
70; This API tears down temporary RAM\r
71;\r
72;----------------------------------------------------------------------------\r
73global ASM_PFX(TempRamExitApi)\r
74ASM_PFX(TempRamExitApi):\r
75 mov eax, 4 ; FSP_API_INDEX.TempRamExitApiIndex\r
76 jmp ASM_PFX(FspApiCommon)\r
77\r
78;----------------------------------------------------------------------------\r
79; FspApiCommonContinue API\r
80;\r
81; This is the FSP API common entry point to resume the FSP execution\r
82;\r
83;----------------------------------------------------------------------------\r
84global ASM_PFX(FspApiCommonContinue)\r
85ASM_PFX(FspApiCommonContinue):\r
86 ;\r
87 ; EAX holds the API index\r
88 ;\r
89\r
90 ;\r
91 ; FspMemoryInit API setup the initial stack frame\r
92 ;\r
93\r
94 ;\r
95 ; Place holder to store the FspInfoHeader pointer\r
96 ;\r
97 push eax\r
98\r
99 ;\r
100 ; Update the FspInfoHeader pointer\r
101 ;\r
102 push eax\r
103 call ASM_PFX(AsmGetFspInfoHeader)\r
104 mov [esp + 4], eax\r
105 pop eax\r
106\r
107 ;\r
108 ; Create a Task Frame in the stack for the Boot Loader\r
109 ;\r
110 pushfd ; 2 pushf for 4 byte alignment\r
111 cli\r
112 pushad\r
113\r
114 ; Reserve 8 bytes for IDT save/restore\r
115 sub esp, 8\r
116 sidt [esp]\r
117\r
118\r
119 ; Get Stackbase and StackSize from FSPM_UPD Param \r
120 mov edx, [esp + API_PARAM1_OFFSET] \r
121 cmp edx, 0\r
122 jnz FspStackSetup \r
123\r
124 ; Get UPD default values if FspmUpdDataPtr (ApiParam1) is null\r
125 push eax\r
126 call ASM_PFX(AsmGetFspInfoHeader)\r
127 mov edx, [eax + FSP_HEADER_IMGBASE_OFFSET]\r
128 add edx, [eax + FSP_HEADER_CFGREG_OFFSET]\r
129 pop eax\r
130 \r
131 FspStackSetup:\r
132 mov edi, [edx + FSPM_UPD_COMMON.StackBase]\r
133 mov ecx, [edx + FSPM_UPD_COMMON.StackSize]\r
134 add edi, ecx\r
135 ;\r
136 ; Setup new FSP stack\r
137 ;\r
138 xchg edi, esp ; Exchange edi and esp, edi will be assigned to the current esp pointer and esp will be Stack base + Stack size\r
139 mov ebx, esp ; Put Stack base + Stack size in ebx\r
140\r
141 ;\r
142 ; Pass the API Idx to SecStartup\r
143 ;\r
144 push eax\r
145\r
146 ;\r
147 ; Pass the BootLoader stack to SecStartup\r
148 ;\r
149 push edi\r
150\r
151 ;\r
152 ; Pass entry point of the PEI core\r
153 ;\r
154 call ASM_PFX(AsmGetFspBaseAddress)\r
155 mov edi, eax\r
156 call ASM_PFX(AsmGetPeiCoreOffset)\r
157 add edi, eax\r
158 push edi\r
159\r
160 ;\r
161 ; Pass BFV into the PEI Core\r
162 ; It uses relative address to calucate the actual boot FV base\r
163 ; For FSP implementation with single FV, PcdFspBootFirmwareVolumeBase and\r
164 ; PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs,\r
165 ; they are different. The code below can handle both cases.\r
166 ;\r
167 call ASM_PFX(AsmGetFspBaseAddress)\r
168 push eax\r
169\r
170 ;\r
171 ; Pass stack base and size into the PEI Core\r
172 ;\r
173 sub ebx, ecx ; Stack base + Stack size - Stack size\r
174 push ebx\r
175 push ecx\r
176\r
177 ;\r
178 ; Pass Control into the PEI Core\r
179 ;\r
180 call ASM_PFX(SecStartup)\r
181 add esp, 4\r
182exit:\r
183 ret\r
184\r
185global ASM_PFX(FspPeiCoreEntryOff)\r
186ASM_PFX(FspPeiCoreEntryOff):\r
187 ;\r
188 ; This value will be pached by the build script\r
189 ;\r
190 DD 0x12345678\r
191\r
192global ASM_PFX(AsmGetPeiCoreOffset)\r
193ASM_PFX(AsmGetPeiCoreOffset):\r
194 mov eax, dword [ASM_PFX(FspPeiCoreEntryOff)]\r
195 ret\r
196\r
197;----------------------------------------------------------------------------\r
198; Module Entrypoint API\r
199;----------------------------------------------------------------------------\r
200global ASM_PFX(_ModuleEntryPoint)\r
201ASM_PFX(_ModuleEntryPoint):\r
202 jmp $\r