;; @file\r
; Provide FSP API entry points.\r
;\r
-; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
-; This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php.\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+; Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.<BR>\r
+; SPDX-License-Identifier: BSD-2-Clause-Patent\r
;;\r
\r
SECTION .text\r
extern ASM_PFX(PcdGet32(PcdTemporaryRamBase))\r
extern ASM_PFX(PcdGet32(PcdTemporaryRamSize))\r
extern ASM_PFX(PcdGet32(PcdFspTemporaryRamSize))\r
+extern ASM_PFX(PcdGet8 (PcdFspHeapSizePercentage))\r
\r
struc FSPM_UPD_COMMON\r
; FSP_UPD_HEADER {\r
.size:\r
endstruc\r
\r
+struc FSPM_UPD_COMMON_FSP24\r
+ ; FSP_UPD_HEADER {\r
+ .FspUpdHeader: resd 8\r
+ ; }\r
+ ; FSPM_ARCH2_UPD {\r
+ .Revision: resb 1\r
+ .Reserved: resb 3\r
+ .Length resd 1\r
+ .StackBase: resq 1\r
+ .StackSize: resq 1\r
+ .BootLoaderTolumSize: resd 1\r
+ .BootMode: resd 1\r
+ .FspEventHandler resq 1\r
+ .Reserved1: resb 24\r
+ ; }\r
+ .size:\r
+endstruc\r
+\r
;\r
; Following functions will be provided in C\r
;\r
sidt [esp]\r
\r
\r
- ; Get Stackbase and StackSize from FSPM_UPD Param \r
- mov edx, [esp + API_PARAM1_OFFSET] \r
+ ; Get Stackbase and StackSize from FSPM_UPD Param\r
+ mov edx, [esp + API_PARAM1_OFFSET]\r
cmp edx, 0\r
- jnz FspStackSetup \r
+ jnz FspStackSetup\r
\r
; Get UPD default values if FspmUpdDataPtr (ApiParam1) is null\r
push eax\r
mov edx, [eax + FSP_HEADER_IMGBASE_OFFSET]\r
add edx, [eax + FSP_HEADER_CFGREG_OFFSET]\r
pop eax\r
- \r
- FspStackSetup:\r
+\r
+FspStackSetup:\r
+ mov ecx, [edx + FSPM_UPD_COMMON.Revision]\r
+ cmp ecx, 3\r
+ jae FspmUpdCommon2\r
+\r
+ ;\r
+ ; StackBase = temp memory base, StackSize = temp memory size\r
+ ;\r
mov edi, [edx + FSPM_UPD_COMMON.StackBase]\r
mov ecx, [edx + FSPM_UPD_COMMON.StackSize]\r
+ jmp ChkFspHeapSize\r
+\r
+FspmUpdCommon2:\r
+ mov edi, [edx + FSPM_UPD_COMMON_FSP24.StackBase]\r
+ mov ecx, [edx + FSPM_UPD_COMMON_FSP24.StackSize]\r
+\r
+ChkFspHeapSize:\r
+ ;\r
+ ; Keep using bootloader stack if heap size % is 0\r
+ ;\r
+ mov bl, BYTE [ASM_PFX(PcdGet8 (PcdFspHeapSizePercentage))]\r
+ cmp bl, 0\r
+ jz SkipStackSwitch\r
+\r
+ ;\r
+ ; Set up a dedicated temp ram stack for FSP if FSP heap size % doesn't equal 0\r
+ ;\r
add edi, ecx\r
;\r
- ; Setup new FSP stack\r
+ ; Switch to new FSP stack\r
+ ;\r
+ 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
+\r
+SkipStackSwitch:\r
+ ;\r
+ ; If heap size % is 0:\r
+ ; EDI is FSPM_UPD_COMMON.StackBase and will hold ESP later (boot loader stack pointer)\r
+ ; ECX is FSPM_UPD_COMMON.StackSize\r
+ ; ESP is boot loader stack pointer (no stack switch)\r
+ ; BL is 0 to indicate no stack switch (EBX will hold FSPM_UPD_COMMON.StackBase later)\r
+ ;\r
+ ; If heap size % is not 0\r
+ ; EDI is boot loader stack pointer\r
+ ; ECX is FSPM_UPD_COMMON.StackSize\r
+ ; ESP is new stack (FSPM_UPD_COMMON.StackBase + FSPM_UPD_COMMON.StackSize)\r
+ ; BL is NOT 0 to indicate stack has switched\r
;\r
- 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
- mov ebx, esp ; Put Stack base + Stack size in ebx\r
+ cmp bl, 0\r
+ jnz StackHasBeenSwitched\r
+\r
+ mov ebx, edi ; Put FSPM_UPD_COMMON.StackBase to ebx as temp memory base\r
+ mov edi, esp ; Put boot loader stack pointer to edi\r
+ jmp StackSetupDone\r
+\r
+StackHasBeenSwitched:\r
+ mov ebx, esp ; Put Stack base + Stack size in ebx\r
+ sub ebx, ecx ; Stack base + Stack size - Stack size as temp memory base\r
+\r
+StackSetupDone:\r
\r
;\r
; Pass the API Idx to SecStartup\r
\r
;\r
; Pass BFV into the PEI Core\r
- ; It uses relative address to calucate the actual boot FV base\r
+ ; It uses relative address to calculate the actual boot FV base\r
; For FSP implementation with single FV, PcdFspBootFirmwareVolumeBase and\r
- ; PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs,\r
+ ; PcdFspAreaBaseAddress are the same. For FSP with multiple FVs,\r
; they are different. The code below can handle both cases.\r
;\r
call ASM_PFX(AsmGetFspBaseAddress)\r
;\r
; Pass stack base and size into the PEI Core\r
;\r
- sub ebx, ecx ; Stack base + Stack size - Stack size\r
push ebx\r
push ecx\r
\r
global ASM_PFX(FspPeiCoreEntryOff)\r
ASM_PFX(FspPeiCoreEntryOff):\r
;\r
- ; This value will be pached by the build script\r
+ ; This value will be patched by the build script\r
;\r
DD 0x12345678\r
\r