2 ; Provide FSP API entry points.
4 ; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 ; This program and the accompanying materials
6 ; are licensed and made available under the terms and conditions of the BSD License
7 ; which accompanies this distribution. The full text of the license may be found at
8 ; http://opensource.org/licenses/bsd-license.php.
10 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 ; Following are fixed PCDs
19 extern ASM_PFX(PcdGet32(PcdTemporaryRamBase))
20 extern ASM_PFX(PcdGet32(PcdTemporaryRamSize))
21 extern ASM_PFX(PcdGet32(PcdFspTemporaryRamSize))
33 .BootLoaderTolumSize: resd 1
41 ; Following functions will be provided in C
43 extern ASM_PFX(SecStartup)
44 extern ASM_PFX(FspApiCommon)
47 ; Following functions will be provided in PlatformSecLib
49 extern ASM_PFX(AsmGetFspBaseAddress)
50 extern ASM_PFX(AsmGetFspInfoHeader)
52 API_PARAM1_OFFSET EQU 34h ; ApiParam1 [ sub esp,8 + pushad + pushfd + push eax + call]
53 FSP_HEADER_IMGBASE_OFFSET EQU 1Ch
54 FSP_HEADER_CFGREG_OFFSET EQU 24h
56 ;----------------------------------------------------------------------------
59 ; This FSP API is called after TempRamInit and initializes the memory.
61 ;----------------------------------------------------------------------------
62 global ASM_PFX(FspMemoryInitApi)
63 ASM_PFX(FspMemoryInitApi):
64 mov eax, 3 ; FSP_API_INDEX.FspMemoryInitApiIndex
65 jmp ASM_PFX(FspApiCommon)
67 ;----------------------------------------------------------------------------
70 ; This API tears down temporary RAM
72 ;----------------------------------------------------------------------------
73 global ASM_PFX(TempRamExitApi)
74 ASM_PFX(TempRamExitApi):
75 mov eax, 4 ; FSP_API_INDEX.TempRamExitApiIndex
76 jmp ASM_PFX(FspApiCommon)
78 ;----------------------------------------------------------------------------
79 ; FspApiCommonContinue API
81 ; This is the FSP API common entry point to resume the FSP execution
83 ;----------------------------------------------------------------------------
84 global ASM_PFX(FspApiCommonContinue)
85 ASM_PFX(FspApiCommonContinue):
87 ; EAX holds the API index
91 ; FspMemoryInit API setup the initial stack frame
95 ; Place holder to store the FspInfoHeader pointer
100 ; Update the FspInfoHeader pointer
103 call ASM_PFX(AsmGetFspInfoHeader)
108 ; Create a Task Frame in the stack for the Boot Loader
110 pushfd ; 2 pushf for 4 byte alignment
114 ; Reserve 8 bytes for IDT save/restore
119 ; Get Stackbase and StackSize from FSPM_UPD Param
120 mov edx, [esp + API_PARAM1_OFFSET]
124 ; Get UPD default values if FspmUpdDataPtr (ApiParam1) is null
126 call ASM_PFX(AsmGetFspInfoHeader)
127 mov edx, [eax + FSP_HEADER_IMGBASE_OFFSET]
128 add edx, [eax + FSP_HEADER_CFGREG_OFFSET]
132 mov edi, [edx + FSPM_UPD_COMMON.StackBase]
133 mov ecx, [edx + FSPM_UPD_COMMON.StackSize]
136 ; Setup new FSP stack
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
139 mov ebx, esp ; Put Stack base + Stack size in ebx
142 ; Pass the API Idx to SecStartup
147 ; Pass the BootLoader stack to SecStartup
152 ; Pass entry point of the PEI core
154 call ASM_PFX(AsmGetFspBaseAddress)
156 call ASM_PFX(AsmGetPeiCoreOffset)
161 ; Pass BFV into the PEI Core
162 ; It uses relative address to calucate the actual boot FV base
163 ; For FSP implementation with single FV, PcdFspBootFirmwareVolumeBase and
164 ; PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs,
165 ; they are different. The code below can handle both cases.
167 call ASM_PFX(AsmGetFspBaseAddress)
171 ; Pass stack base and size into the PEI Core
173 sub ebx, ecx ; Stack base + Stack size - Stack size
178 ; Pass Control into the PEI Core
180 call ASM_PFX(SecStartup)
185 global ASM_PFX(FspPeiCoreEntryOff)
186 ASM_PFX(FspPeiCoreEntryOff):
188 ; This value will be pached by the build script
192 global ASM_PFX(AsmGetPeiCoreOffset)
193 ASM_PFX(AsmGetPeiCoreOffset):
194 mov eax, dword [ASM_PFX(FspPeiCoreEntryOff)]
197 ;----------------------------------------------------------------------------
200 ; Empty function for WHOLEARCHIVE build option
202 ;----------------------------------------------------------------------------
203 global ASM_PFX(TempRamInitApi)
204 ASM_PFX(TempRamInitApi):
208 ;----------------------------------------------------------------------------
209 ; Module Entrypoint API
210 ;----------------------------------------------------------------------------
211 global ASM_PFX(_ModuleEntryPoint)
212 ASM_PFX(_ModuleEntryPoint):