-;------------------------------------------------------------------------------\r
+;; @file\r
+; Provide FSP API entry points.\r
;\r
-; Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2014 - 2015, 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
;\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
-;\r
-; Abstract:\r
-;\r
-; Provide FSP API entry points.\r
-;\r
-;------------------------------------------------------------------------------\r
+;;\r
\r
.586p\r
.model flat,C\r
EXTERN PcdGet32(PcdTemporaryRamBase):DWORD\r
EXTERN PcdGet32(PcdTemporaryRamSize):DWORD\r
EXTERN PcdGet32(PcdFspTemporaryRamSize):DWORD\r
+EXTERN PcdGet32(PcdFspAreaSize):DWORD\r
\r
;\r
; Following functions will be provided in C\r
;\r
-EXTERN FspImageSizeOffset:DWORD\r
+\r
EXTERN SecStartup:PROC\r
EXTERN FspApiCallingCheck:PROC\r
\r
;\r
EXTERN GetFspBaseAddress:PROC\r
EXTERN GetBootFirmwareVolumeOffset:PROC\r
-EXTERN PlatformTempRamInit:PROC\r
EXTERN Pei2LoaderSwitchStack:PROC\r
EXTERN FspSelfCheck(FspSelfCheckDflt):PROC\r
EXTERN PlatformBasicInit(PlatformBasicInitDflt):PROC\r
EXTERN LoadUcode(LoadUcodeDflt):PROC\r
+EXTERN SecPlatformInit:PROC\r
+EXTERN SecCarInit:PROC\r
\r
;\r
; Define the data length that we saved on the stack top\r
DATA_LEN_OF_MCUD EQU 18h\r
DATA_LEN_AT_STACK_TOP EQU (DATA_LEN_OF_PER0 + DATA_LEN_OF_MCUD + 4)\r
\r
+;\r
+; Define SSE macros\r
+;\r
+LOAD_MMX_EXT MACRO ReturnAddress, MmxRegister\r
+ mov esi, ReturnAddress\r
+ movd MmxRegister, esi ; save ReturnAddress into MM7 \r
+ENDM\r
+\r
+CALL_MMX_EXT MACRO RoutineLabel, MmxRegister\r
+ local ReturnAddress\r
+ mov esi, offset ReturnAddress\r
+ movd MmxRegister, esi ; save ReturnAddress into MM7\r
+ jmp RoutineLabel\r
+ReturnAddress:\r
+ENDM\r
+\r
+RET_ESI_EXT MACRO MmxRegister\r
+ movd esi, MmxRegister ; restore ESP from MM7\r
+ jmp esi\r
+ENDM\r
+\r
+CALL_MMX MACRO RoutineLabel\r
+ CALL_MMX_EXT RoutineLabel, mm7\r
+ENDM\r
+\r
+RET_ESI MACRO\r
+ RET_ESI_EXT mm7 \r
+ENDM\r
+\r
;------------------------------------------------------------------------------\r
FspSelfCheckDflt PROC NEAR PUBLIC\r
; Inputs:\r
;\r
;\r
; Save return address to EBP\r
- mov ebp, eax\r
+ movd ebp, mm7\r
\r
cmp esp, 0\r
jz paramerror\r
\r
LoadUcodeDflt ENDP\r
\r
+EstablishStackFsp PROC NEAR PRIVATE\r
+ ; Following is the code copied from BYTFSP, need to figure out what it is doing..\r
+ ;\r
+ ; Save parameter pointer in edx \r
+ ;\r
+ mov edx, dword ptr [esp + 4] \r
+ \r
+ ;\r
+ ; Enable FSP STACK\r
+ ;\r
+ mov esp, PcdGet32 (PcdTemporaryRamBase)\r
+ add esp, PcdGet32 (PcdTemporaryRamSize) \r
+\r
+ push DATA_LEN_OF_MCUD ; Size of the data region \r
+ push 4455434Dh ; Signature of the data region 'MCUD'\r
+ push dword ptr [edx + 12] ; Code size\r
+ push dword ptr [edx + 8] ; Code base\r
+ cmp edx, 0 ; Is parameter pointer valid ?\r
+ jz InvalidMicrocodeRegion\r
+ push dword ptr [edx + 4] ; Microcode size\r
+ push dword ptr [edx] ; Microcode base \r
+ jmp @F\r
+\r
+InvalidMicrocodeRegion:\r
+ push 0 ; Microcode size\r
+ push 0 ; Microcode base\r
+ \r
+@@:\r
+ ;\r
+ ; Save API entry/exit timestamp into stack\r
+ ;\r
+ push DATA_LEN_OF_PER0 ; Size of the data region \r
+ push 30524550h ; Signature of the data region 'PER0'\r
+ movd eax, xmm4\r
+ push eax\r
+ movd eax, xmm5\r
+ push eax\r
+ rdtsc\r
+ push edx\r
+ push eax\r
+\r
+ ;\r
+ ; Terminator for the data on stack\r
+ ; \r
+ push 0\r
+\r
+ ;\r
+ ; Set ECX/EDX to the bootloader temporary memory range\r
+ ;\r
+ mov ecx, PcdGet32 (PcdTemporaryRamBase)\r
+ mov edx, ecx\r
+ add edx, PcdGet32 (PcdTemporaryRamSize)\r
+ sub edx, PcdGet32 (PcdFspTemporaryRamSize)\r
+\r
+ xor eax, eax\r
+ \r
+ RET_ESI\r
+\r
+EstablishStackFsp ENDP\r
+\r
+\r
;----------------------------------------------------------------------------\r
; TempRamInit API\r
;\r
; Save timestamp into XMM4 & XMM5\r
;\r
rdtsc\r
- SAVE_EAX\r
- SAVE_EDX\r
-\r
- ;\r
- ; Check Parameter\r
- ;\r
- mov eax, dword ptr [esp + 4]\r
- cmp eax, 0\r
- mov eax, 80000002h\r
- jz NemInitExit\r
-\r
+ movd xmm4, edx\r
+ movd xmm5, eax\r
+ \r
;\r
; CPUID/DeviceID check\r
;\r
cmp eax, 0\r
jnz NemInitExit\r
\r
- ;\r
- ; Platform Basic Init.\r
- ;\r
- mov eax, @F\r
- jmp PlatformBasicInit\r
-@@:\r
- cmp eax, 0\r
- jnz NemInitExit\r
+ CALL_MMX SecPlatformInit\r
\r
- ;\r
+ ; Call Sec CAR Init\r
+ CALL_MMX SecCarInit\r
+ \r
+ ; @todo: ESP has been modified, we need to restore here.\r
+ LOAD_REGS\r
+ SAVE_REGS\r
; Load microcode\r
- ;\r
- mov eax, @F\r
- add esp, 4\r
- jmp LoadUcode\r
-@@:\r
- LOAD_ESP\r
- cmp eax, 0\r
- jnz NemInitExit\r
-\r
- ;\r
- ; Call platform NEM init\r
- ;\r
- mov eax, @F\r
- add esp, 4\r
- jmp PlatformTempRamInit\r
-@@:\r
- LOAD_ESP\r
- cmp eax, 0\r
- jnz NemInitExit\r
-\r
- ;\r
- ; Save parameter pointer in edx\r
- ;\r
- mov edx, dword ptr [esp + 4]\r
-\r
- ;\r
- ; Enable FSP STACK\r
- ;\r
- mov esp, PcdGet32(PcdTemporaryRamBase)\r
- add esp, PcdGet32(PcdTemporaryRamSize)\r
-\r
- push DATA_LEN_OF_MCUD ; Size of the data region\r
- push 4455434Dh ; Signature of the data region 'MCUD'\r
- push dword ptr [edx + 4] ; Microcode size\r
- push dword ptr [edx + 0] ; Microcode base\r
- push dword ptr [edx + 12] ; Code size\r
- push dword ptr [edx + 8] ; Code base\r
-\r
- ;\r
- ; Save API entry/exit timestamp into stack\r
- ;\r
- push DATA_LEN_OF_PER0 ; Size of the data region\r
- push 30524550h ; Signature of the data region 'PER0'\r
- rdtsc\r
- push edx\r
- push eax\r
- LOAD_EAX\r
- LOAD_EDX\r
- push edx\r
- push eax\r
-\r
- ;\r
- ; Terminator for the data on stack\r
- ;\r
- push 0\r
+ CALL_MMX LoadUcode\r
\r
- ;\r
- ; Set ECX/EDX to the bootloader temporary memory range\r
- ;\r
- mov ecx, PcdGet32(PcdTemporaryRamBase)\r
- mov edx, ecx\r
- add edx, PcdGet32(PcdTemporaryRamSize)\r
- sub edx, PcdGet32(PcdFspTemporaryRamSize)\r
-\r
- xor eax, eax\r
+ CALL_MMX EstablishStackFsp\r
\r
NemInitExit:\r
;\r
;\r
;----------------------------------------------------------------------------\r
FspInitApi PROC NEAR PUBLIC\r
+ mov eax, 1\r
+ jmp FspApiCommon\r
+ FspInitApi ENDP\r
+\r
+;----------------------------------------------------------------------------\r
+; NotifyPhase API\r
+;\r
+; This FSP API will notify the FSP about the different phases in the boot\r
+; process\r
+;\r
+;----------------------------------------------------------------------------\r
+NotifyPhaseApi PROC C PUBLIC\r
+ mov eax, 2\r
+ jmp FspApiCommon\r
+NotifyPhaseApi ENDP\r
+\r
+;----------------------------------------------------------------------------\r
+; FspMemoryInit API\r
+;\r
+; This FSP API is called after TempRamInit and initializes the memory.\r
+;\r
+;----------------------------------------------------------------------------\r
+FspMemoryInitApi PROC NEAR PUBLIC\r
+ mov eax, 3\r
+ jmp FspApiCommon\r
+FspMemoryInitApi ENDP\r
+\r
+\r
+;----------------------------------------------------------------------------\r
+; TempRamExitApi API\r
+;\r
+; This API tears down temporary RAM\r
+;\r
+;----------------------------------------------------------------------------\r
+TempRamExitApi PROC C PUBLIC\r
+ mov eax, 4\r
+ jmp FspApiCommon\r
+TempRamExitApi ENDP\r
+\r
+\r
+;----------------------------------------------------------------------------\r
+; FspSiliconInit API\r
+;\r
+; This FSP API initializes the CPU and the chipset including the IO\r
+; controllers in the chipset to enable normal operation of these devices.\r
+;\r
+;----------------------------------------------------------------------------\r
+FspSiliconInitApi PROC C PUBLIC\r
+ mov eax, 5\r
+ jmp FspApiCommon\r
+FspSiliconInitApi ENDP\r
+\r
+;----------------------------------------------------------------------------\r
+; FspApiCommon API\r
+;\r
+; This is the FSP API common entry point to resume the FSP execution\r
+;\r
+;----------------------------------------------------------------------------\r
+FspApiCommon PROC C PUBLIC\r
;\r
- ; Stack must be ready\r
+ ; EAX holds the API index\r
;\r
- push 087654321h\r
- pop eax\r
- cmp eax, 087654321h\r
+\r
+ ;\r
+ ; Stack must be ready\r
+ ; \r
+ push eax\r
+ add esp, 4\r
+ cmp eax, dword ptr [esp - 4]\r
jz @F\r
mov eax, 080000003h\r
jmp exit\r
\r
@@:\r
;\r
- ; Additional check\r
+ ; Verify the calling condition\r
;\r
pushad\r
- push 1\r
+ push eax\r
call FspApiCallingCheck\r
add esp, 4\r
- mov dword ptr [esp + 4 * 7], eax\r
- popad\r
cmp eax, 0\r
jz @F\r
- jmp exit\r
+ mov dword ptr [esp + 4 * 7], eax\r
+ popad\r
+ ret\r
\r
@@:\r
+ popad\r
+ cmp eax, 1 ; FspInit API\r
+ jz @F\r
+ cmp eax, 3 ; FspMemoryInit API\r
+ jz @F\r
+ jmp Pei2LoaderSwitchStack\r
+\r
+@@: \r
+ ;\r
+ ; FspInit and FspMemoryInit APIs, setup the initial stack frame\r
+ ; \r
+ \r
;\r
; Store the address in FSP which will return control to the BL\r
;\r
\r
; Reserve 8 bytes for IDT save/restore\r
sub esp, 8\r
- sidt fword ptr [esp]\r
+ sidt fword ptr [esp] \r
\r
;\r
; Setup new FSP stack\r
;\r
- mov eax, esp\r
+ mov edi, esp\r
mov esp, PcdGet32(PcdTemporaryRamBase)\r
add esp, PcdGet32(PcdTemporaryRamSize)\r
sub esp, (DATA_LEN_AT_STACK_TOP + 40h)\r
\r
;\r
- ; Save the bootloader's stack pointer\r
+ ; Pass the API Idx to SecStartup\r
;\r
push eax\r
+ \r
+ ;\r
+ ; Pass the bootloader stack to SecStartup\r
+ ;\r
+ push edi\r
\r
;\r
; Pass entry point of the PEI core\r
;\r
call GetFspBaseAddress\r
- mov edi, FspImageSizeOffset\r
- mov edi, DWORD PTR [eax + edi]\r
- add edi, eax\r
+ mov edi, eax\r
+ add edi, PcdGet32 (PcdFspAreaSize) \r
sub edi, 20h\r
- add eax, DWORD PTR [edi]\r
+ add eax, DWORD PTR ds:[edi]\r
push eax\r
\r
;\r
;\r
call SecStartup\r
\r
-exit:\r
+exit: \r
ret\r
\r
-FspInitApi ENDP\r
-\r
-;----------------------------------------------------------------------------\r
-; NotifyPhase API\r
-;\r
-; This FSP API will notify the FSP about the different phases in the boot\r
-; process\r
-;\r
-;----------------------------------------------------------------------------\r
-NotifyPhaseApi PROC C PUBLIC\r
- ;\r
- ; Stack must be ready\r
- ;\r
- push 087654321h\r
- pop eax\r
- cmp eax, 087654321h\r
- jz @F\r
- mov eax, 080000003h\r
- jmp err_exit\r
-\r
-@@:\r
- ;\r
- ; Verify the calling condition\r
- ;\r
- pushad\r
- push 2\r
- call FspApiCallingCheck\r
- add esp, 4\r
- mov dword ptr [esp + 4 * 7], eax\r
- popad\r
-\r
- cmp eax, 0\r
- jz @F\r
-\r
- ;\r
- ; Error return\r
- ;\r
-err_exit:\r
- ret\r
-\r
-@@:\r
- jmp Pei2LoaderSwitchStack\r
-\r
-NotifyPhaseApi ENDP\r
-\r
+FspApiCommon ENDP\r
\r
END\r