2015-02-11 03:57:40 +01:00
|
|
|
;; @file
|
|
|
|
; Provide FSP API entry points.
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
; Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
|
2014-07-29 04:21:52 +02:00
|
|
|
; This program and the accompanying materials
|
|
|
|
; are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
; which accompanies this distribution. The full text of the license may be found at
|
|
|
|
; http://opensource.org/licenses/bsd-license.php.
|
|
|
|
;
|
|
|
|
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2015-02-11 03:57:40 +01:00
|
|
|
;;
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
.586p
|
|
|
|
.model flat,C
|
|
|
|
.code
|
|
|
|
.xmm
|
|
|
|
|
|
|
|
INCLUDE SaveRestoreSse.inc
|
2015-04-23 10:52:21 +02:00
|
|
|
INCLUDE MicrocodeLoad.inc
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
; Following are fixed PCDs
|
|
|
|
;
|
|
|
|
EXTERN PcdGet32(PcdTemporaryRamBase):DWORD
|
|
|
|
EXTERN PcdGet32(PcdTemporaryRamSize):DWORD
|
|
|
|
EXTERN PcdGet32(PcdFspTemporaryRamSize):DWORD
|
2015-02-11 03:57:40 +01:00
|
|
|
EXTERN PcdGet32(PcdFspAreaSize):DWORD
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
; Following functions will be provided in C
|
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
EXTERN SecStartup:PROC
|
|
|
|
EXTERN FspApiCallingCheck:PROC
|
|
|
|
|
|
|
|
;
|
|
|
|
; Following functions will be provided in PlatformSecLib
|
|
|
|
;
|
|
|
|
EXTERN GetFspBaseAddress:PROC
|
2015-04-29 05:10:24 +02:00
|
|
|
EXTERN GetFspInfoHdr:PROC
|
2014-07-29 04:21:52 +02:00
|
|
|
EXTERN GetBootFirmwareVolumeOffset:PROC
|
2015-04-29 05:10:24 +02:00
|
|
|
EXTERN Loader2PeiSwitchStack:PROC
|
2015-04-23 10:52:21 +02:00
|
|
|
EXTERN LoadMicrocode(LoadMicrocodeDefault):PROC
|
2015-02-12 08:37:30 +01:00
|
|
|
EXTERN SecPlatformInit(SecPlatformInitDefault):PROC
|
2015-02-11 03:57:40 +01:00
|
|
|
EXTERN SecCarInit:PROC
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
; Define the data length that we saved on the stack top
|
|
|
|
;
|
|
|
|
DATA_LEN_OF_PER0 EQU 18h
|
|
|
|
DATA_LEN_OF_MCUD EQU 18h
|
|
|
|
DATA_LEN_AT_STACK_TOP EQU (DATA_LEN_OF_PER0 + DATA_LEN_OF_MCUD + 4)
|
|
|
|
|
2015-02-11 03:57:40 +01:00
|
|
|
;
|
|
|
|
; Define SSE macros
|
|
|
|
;
|
|
|
|
LOAD_MMX_EXT MACRO ReturnAddress, MmxRegister
|
|
|
|
mov esi, ReturnAddress
|
2015-02-13 02:20:35 +01:00
|
|
|
movd MmxRegister, esi ; save ReturnAddress into MMX
|
2015-02-11 03:57:40 +01:00
|
|
|
ENDM
|
|
|
|
|
|
|
|
CALL_MMX_EXT MACRO RoutineLabel, MmxRegister
|
|
|
|
local ReturnAddress
|
|
|
|
mov esi, offset ReturnAddress
|
2015-02-13 02:20:35 +01:00
|
|
|
movd MmxRegister, esi ; save ReturnAddress into MMX
|
2015-02-11 03:57:40 +01:00
|
|
|
jmp RoutineLabel
|
|
|
|
ReturnAddress:
|
|
|
|
ENDM
|
|
|
|
|
|
|
|
RET_ESI_EXT MACRO MmxRegister
|
2015-04-23 10:52:21 +02:00
|
|
|
movd esi, MmxRegister ; move ReturnAddress from MMX to ESI
|
2015-02-11 03:57:40 +01:00
|
|
|
jmp esi
|
|
|
|
ENDM
|
|
|
|
|
|
|
|
CALL_MMX MACRO RoutineLabel
|
|
|
|
CALL_MMX_EXT RoutineLabel, mm7
|
|
|
|
ENDM
|
|
|
|
|
|
|
|
RET_ESI MACRO
|
2015-04-23 10:52:21 +02:00
|
|
|
RET_ESI_EXT mm7
|
2015-02-11 03:57:40 +01:00
|
|
|
ENDM
|
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
;------------------------------------------------------------------------------
|
2015-02-12 08:37:30 +01:00
|
|
|
SecPlatformInitDefault PROC NEAR PUBLIC
|
2014-07-29 04:21:52 +02:00
|
|
|
; Inputs:
|
2015-02-13 02:20:35 +01:00
|
|
|
; mm7 -> Return address
|
2014-07-29 04:21:52 +02:00
|
|
|
; Outputs:
|
|
|
|
; eax -> 0 - Successful, Non-zero - Failed.
|
|
|
|
; Register Usage:
|
|
|
|
; eax is cleared and ebp is used for return address.
|
|
|
|
; All others reserved.
|
2015-02-13 02:20:35 +01:00
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
; Save return address to EBP
|
2015-02-13 07:17:23 +01:00
|
|
|
movd ebp, mm7
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
exit:
|
|
|
|
jmp ebp
|
2015-02-12 08:37:30 +01:00
|
|
|
SecPlatformInitDefault ENDP
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
2015-04-23 10:52:21 +02:00
|
|
|
LoadMicrocodeDefault PROC NEAR PUBLIC
|
2014-07-29 04:21:52 +02:00
|
|
|
; Inputs:
|
2015-04-23 10:52:21 +02:00
|
|
|
; esp -> LoadMicrocodeParams pointer
|
2014-07-29 04:21:52 +02:00
|
|
|
; Register Usage:
|
|
|
|
; esp Preserved
|
|
|
|
; All others destroyed
|
|
|
|
; Assumptions:
|
|
|
|
; No memory available, stack is hard-coded and used for return address
|
|
|
|
; Executed by SBSP and NBSP
|
|
|
|
; Beginning of microcode update region starts on paragraph boundary
|
|
|
|
|
|
|
|
;
|
|
|
|
;
|
|
|
|
; Save return address to EBP
|
2015-02-11 03:57:40 +01:00
|
|
|
movd ebp, mm7
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
cmp esp, 0
|
|
|
|
jz paramerror
|
2015-04-23 10:52:21 +02:00
|
|
|
mov eax, dword ptr [esp + 4] ; Parameter pointer
|
2014-07-29 04:21:52 +02:00
|
|
|
cmp eax, 0
|
|
|
|
jz paramerror
|
|
|
|
mov esp, eax
|
2015-04-23 10:52:21 +02:00
|
|
|
mov esi, [esp].LoadMicrocodeParams.MicrocodeCodeAddr
|
2014-07-29 04:21:52 +02:00
|
|
|
cmp esi, 0
|
|
|
|
jnz check_main_header
|
|
|
|
|
|
|
|
paramerror:
|
|
|
|
mov eax, 080000002h
|
|
|
|
jmp exit
|
|
|
|
|
2015-04-23 10:52:21 +02:00
|
|
|
mov esi, [esp].LoadMicrocodeParams.MicrocodeCodeAddr
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
check_main_header:
|
|
|
|
; Get processor signature and platform ID from the installed processor
|
|
|
|
; and save into registers for later use
|
|
|
|
; ebx = processor signature
|
|
|
|
; edx = platform ID
|
|
|
|
mov eax, 1
|
|
|
|
cpuid
|
|
|
|
mov ebx, eax
|
|
|
|
mov ecx, MSR_IA32_PLATFORM_ID
|
|
|
|
rdmsr
|
|
|
|
mov ecx, edx
|
|
|
|
shr ecx, 50-32
|
|
|
|
and ecx, 7h
|
|
|
|
mov edx, 1
|
|
|
|
shl edx, cl
|
|
|
|
|
|
|
|
; Current register usage
|
|
|
|
; esp -> stack with paramters
|
|
|
|
; esi -> microcode update to check
|
|
|
|
; ebx = processor signature
|
|
|
|
; edx = platform ID
|
|
|
|
|
|
|
|
; Check for valid microcode header
|
|
|
|
; Minimal test checking for header version and loader version as 1
|
|
|
|
mov eax, dword ptr 1
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp [esi].MicrocodeHdr.MicrocodeHdrVersion, eax
|
2014-07-29 04:21:52 +02:00
|
|
|
jne advance_fixed_size
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp [esi].MicrocodeHdr.MicrocodeHdrLoader, eax
|
2014-07-29 04:21:52 +02:00
|
|
|
jne advance_fixed_size
|
|
|
|
|
|
|
|
; Check if signature and plaform ID match
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp ebx, [esi].MicrocodeHdr.MicrocodeHdrProcessor
|
2014-07-29 04:21:52 +02:00
|
|
|
jne @f
|
2015-04-23 10:52:21 +02:00
|
|
|
test edx, [esi].MicrocodeHdr.MicrocodeHdrFlags
|
2014-07-29 04:21:52 +02:00
|
|
|
jnz load_check ; Jif signature and platform ID match
|
|
|
|
|
|
|
|
@@:
|
|
|
|
; Check if extended header exists
|
2015-04-23 10:52:21 +02:00
|
|
|
; First check if MicrocodeHdrTotalSize and MicrocodeHdrDataSize are valid
|
2014-07-29 04:21:52 +02:00
|
|
|
xor eax, eax
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp [esi].MicrocodeHdr.MicrocodeHdrTotalSize, eax
|
2014-07-29 04:21:52 +02:00
|
|
|
je next_microcode
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp [esi].MicrocodeHdr.MicrocodeHdrDataSize, eax
|
2014-07-29 04:21:52 +02:00
|
|
|
je next_microcode
|
|
|
|
|
|
|
|
; Then verify total size - sizeof header > data size
|
2015-04-23 10:52:21 +02:00
|
|
|
mov ecx, [esi].MicrocodeHdr.MicrocodeHdrTotalSize
|
|
|
|
sub ecx, sizeof MicrocodeHdr
|
|
|
|
cmp ecx, [esi].MicrocodeHdr.MicrocodeHdrDataSize
|
2014-07-29 04:21:52 +02:00
|
|
|
jng next_microcode ; Jif extended header does not exist
|
|
|
|
|
|
|
|
; Set edi -> extended header
|
|
|
|
mov edi, esi
|
2015-04-23 10:52:21 +02:00
|
|
|
add edi, sizeof MicrocodeHdr
|
|
|
|
add edi, [esi].MicrocodeHdr.MicrocodeHdrDataSize
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
; Get count of extended structures
|
2015-04-23 10:52:21 +02:00
|
|
|
mov ecx, [edi].ExtSigHdr.ExtSigHdrCount
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
; Move pointer to first signature structure
|
2015-04-23 10:52:21 +02:00
|
|
|
add edi, sizeof ExtSigHdr
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
check_ext_sig:
|
|
|
|
; Check if extended signature and platform ID match
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp [edi].ExtSig.ExtSigProcessor, ebx
|
2014-07-29 04:21:52 +02:00
|
|
|
jne @f
|
2015-04-23 10:52:21 +02:00
|
|
|
test [edi].ExtSig.ExtSigFlags, edx
|
2014-07-29 04:21:52 +02:00
|
|
|
jnz load_check ; Jif signature and platform ID match
|
|
|
|
@@:
|
|
|
|
; Check if any more extended signatures exist
|
2015-04-23 10:52:21 +02:00
|
|
|
add edi, sizeof ExtSig
|
2014-07-29 04:21:52 +02:00
|
|
|
loop check_ext_sig
|
|
|
|
|
|
|
|
next_microcode:
|
|
|
|
; Advance just after end of this microcode
|
|
|
|
xor eax, eax
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp [esi].MicrocodeHdr.MicrocodeHdrTotalSize, eax
|
2014-07-29 04:21:52 +02:00
|
|
|
je @f
|
2015-04-23 10:52:21 +02:00
|
|
|
add esi, [esi].MicrocodeHdr.MicrocodeHdrTotalSize
|
2014-07-29 04:21:52 +02:00
|
|
|
jmp check_address
|
|
|
|
@@:
|
|
|
|
add esi, dword ptr 2048
|
|
|
|
jmp check_address
|
|
|
|
|
|
|
|
advance_fixed_size:
|
|
|
|
; Advance by 4X dwords
|
|
|
|
add esi, dword ptr 1024
|
|
|
|
|
|
|
|
check_address:
|
|
|
|
; Is valid Microcode start point ?
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp dword ptr [esi].MicrocodeHdr.MicrocodeHdrVersion, 0ffffffffh
|
2014-07-29 04:21:52 +02:00
|
|
|
jz done
|
|
|
|
|
2014-12-06 01:29:04 +01:00
|
|
|
; Is automatic size detection ?
|
2015-04-23 10:52:21 +02:00
|
|
|
mov eax, [esp].LoadMicrocodeParams.MicrocodeCodeSize
|
2014-12-06 01:29:04 +01:00
|
|
|
cmp eax, 0ffffffffh
|
|
|
|
jz @f
|
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
; Address >= microcode region address + microcode region size?
|
2015-04-23 10:52:21 +02:00
|
|
|
add eax, [esp].LoadMicrocodeParams.MicrocodeCodeAddr
|
2014-07-29 04:21:52 +02:00
|
|
|
cmp esi, eax
|
2015-04-23 10:52:21 +02:00
|
|
|
jae done ;Jif address is outside of microcode region
|
2014-07-29 04:21:52 +02:00
|
|
|
jmp check_main_header
|
|
|
|
|
2014-12-06 01:29:04 +01:00
|
|
|
@@:
|
2014-07-29 04:21:52 +02:00
|
|
|
load_check:
|
|
|
|
; Get the revision of the current microcode update loaded
|
|
|
|
mov ecx, MSR_IA32_BIOS_SIGN_ID
|
|
|
|
xor eax, eax ; Clear EAX
|
|
|
|
xor edx, edx ; Clear EDX
|
|
|
|
wrmsr ; Load 0 to MSR at 8Bh
|
|
|
|
|
|
|
|
mov eax, 1
|
|
|
|
cpuid
|
|
|
|
mov ecx, MSR_IA32_BIOS_SIGN_ID
|
|
|
|
rdmsr ; Get current microcode signature
|
|
|
|
|
|
|
|
; Verify this microcode update is not already loaded
|
2015-04-23 10:52:21 +02:00
|
|
|
cmp [esi].MicrocodeHdr.MicrocodeHdrRevision, edx
|
2014-07-29 04:21:52 +02:00
|
|
|
je continue
|
|
|
|
|
|
|
|
load_microcode:
|
|
|
|
; EAX contains the linear address of the start of the Update Data
|
|
|
|
; EDX contains zero
|
|
|
|
; ECX contains 79h (IA32_BIOS_UPDT_TRIG)
|
|
|
|
; Start microcode load with wrmsr
|
|
|
|
mov eax, esi
|
2015-04-23 10:52:21 +02:00
|
|
|
add eax, sizeof MicrocodeHdr
|
2014-07-29 04:21:52 +02:00
|
|
|
xor edx, edx
|
|
|
|
mov ecx, MSR_IA32_BIOS_UPDT_TRIG
|
|
|
|
wrmsr
|
|
|
|
mov eax, 1
|
|
|
|
cpuid
|
|
|
|
|
|
|
|
continue:
|
|
|
|
jmp next_microcode
|
|
|
|
|
|
|
|
done:
|
|
|
|
mov eax, 1
|
|
|
|
cpuid
|
|
|
|
mov ecx, MSR_IA32_BIOS_SIGN_ID
|
|
|
|
rdmsr ; Get current microcode signature
|
|
|
|
xor eax, eax
|
|
|
|
cmp edx, 0
|
|
|
|
jnz exit
|
|
|
|
mov eax, 08000000Eh
|
|
|
|
|
|
|
|
exit:
|
|
|
|
jmp ebp
|
|
|
|
|
2015-04-23 10:52:21 +02:00
|
|
|
LoadMicrocodeDefault ENDP
|
2014-07-29 04:21:52 +02:00
|
|
|
|
2015-02-11 03:57:40 +01:00
|
|
|
EstablishStackFsp PROC NEAR PRIVATE
|
|
|
|
;
|
2015-04-23 10:52:21 +02:00
|
|
|
; Save parameter pointer in edx
|
2015-02-11 03:57:40 +01:00
|
|
|
;
|
2015-04-23 10:52:21 +02:00
|
|
|
mov edx, dword ptr [esp + 4]
|
|
|
|
|
2015-02-11 03:57:40 +01:00
|
|
|
;
|
|
|
|
; Enable FSP STACK
|
|
|
|
;
|
|
|
|
mov esp, PcdGet32 (PcdTemporaryRamBase)
|
2015-04-23 10:52:21 +02:00
|
|
|
add esp, PcdGet32 (PcdTemporaryRamSize)
|
2015-02-11 03:57:40 +01:00
|
|
|
|
2015-04-23 10:52:21 +02:00
|
|
|
push DATA_LEN_OF_MCUD ; Size of the data region
|
2015-02-11 03:57:40 +01:00
|
|
|
push 4455434Dh ; Signature of the data region 'MCUD'
|
|
|
|
push dword ptr [edx + 12] ; Code size
|
|
|
|
push dword ptr [edx + 8] ; Code base
|
|
|
|
push dword ptr [edx + 4] ; Microcode size
|
2015-04-23 10:52:21 +02:00
|
|
|
push dword ptr [edx] ; Microcode base
|
2015-02-11 03:57:40 +01:00
|
|
|
|
|
|
|
;
|
|
|
|
; Save API entry/exit timestamp into stack
|
|
|
|
;
|
|
|
|
push DATA_LEN_OF_PER0 ; Size of the data region
|
|
|
|
push 30524550h ; Signature of the data region 'PER0'
|
2015-02-12 08:02:43 +01:00
|
|
|
LOAD_EDX
|
|
|
|
push edx
|
|
|
|
LOAD_EAX
|
2015-02-11 03:57:40 +01:00
|
|
|
push eax
|
|
|
|
rdtsc
|
|
|
|
push edx
|
|
|
|
push eax
|
|
|
|
|
|
|
|
;
|
|
|
|
; Terminator for the data on stack
|
|
|
|
;
|
|
|
|
push 0
|
|
|
|
|
|
|
|
;
|
2015-04-23 10:52:21 +02:00
|
|
|
; Set ECX/EDX to the BootLoader temporary memory range
|
2015-02-11 03:57:40 +01:00
|
|
|
;
|
|
|
|
mov ecx, PcdGet32 (PcdTemporaryRamBase)
|
|
|
|
mov edx, ecx
|
|
|
|
add edx, PcdGet32 (PcdTemporaryRamSize)
|
|
|
|
sub edx, PcdGet32 (PcdFspTemporaryRamSize)
|
|
|
|
|
|
|
|
xor eax, eax
|
2015-04-23 10:52:21 +02:00
|
|
|
|
2015-02-11 03:57:40 +01:00
|
|
|
RET_ESI
|
|
|
|
|
|
|
|
EstablishStackFsp ENDP
|
|
|
|
|
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; TempRamInit API
|
|
|
|
;
|
|
|
|
; This FSP API will load the microcode update, enable code caching for the
|
|
|
|
; region specified by the boot loader and also setup a temporary stack to be
|
|
|
|
; used till main memory is initialized.
|
|
|
|
;
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
TempRamInitApi PROC NEAR PUBLIC
|
|
|
|
;
|
|
|
|
; Ensure SSE is enabled
|
|
|
|
;
|
|
|
|
ENABLE_SSE
|
|
|
|
|
|
|
|
;
|
|
|
|
; Save EBP, EBX, ESI, EDI & ESP in XMM7 & XMM6
|
|
|
|
;
|
|
|
|
SAVE_REGS
|
|
|
|
|
|
|
|
;
|
2015-02-13 02:20:35 +01:00
|
|
|
; Save timestamp into XMM6
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
|
|
|
rdtsc
|
2015-02-12 08:02:43 +01:00
|
|
|
SAVE_EAX
|
|
|
|
SAVE_EDX
|
|
|
|
|
|
|
|
;
|
|
|
|
; Check Parameter
|
|
|
|
;
|
|
|
|
mov eax, dword ptr [esp + 4]
|
|
|
|
cmp eax, 0
|
|
|
|
mov eax, 80000002h
|
|
|
|
jz NemInitExit
|
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
2015-04-29 05:10:24 +02:00
|
|
|
; Sec Platform Init
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
CALL_MMX SecPlatformInit
|
2015-02-12 08:02:43 +01:00
|
|
|
cmp eax, 0
|
|
|
|
jnz NemInitExit
|
2015-02-11 03:57:40 +01:00
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
; Load microcode
|
2015-02-12 08:02:43 +01:00
|
|
|
LOAD_ESP
|
2015-04-23 10:52:21 +02:00
|
|
|
CALL_MMX LoadMicrocode
|
|
|
|
SXMMN xmm6, 3, eax ;Save microcode return status in ECX-SLOT 3 in xmm6.
|
|
|
|
;@note If return value eax is not 0, microcode did not load, but continue and attempt to boot.
|
2015-02-12 08:02:43 +01:00
|
|
|
|
|
|
|
; Call Sec CAR Init
|
|
|
|
LOAD_ESP
|
|
|
|
CALL_MMX SecCarInit
|
|
|
|
cmp eax, 0
|
|
|
|
jnz NemInitExit
|
2014-07-29 04:21:52 +02:00
|
|
|
|
2015-02-12 08:02:43 +01:00
|
|
|
LOAD_ESP
|
2015-02-11 03:57:40 +01:00
|
|
|
CALL_MMX EstablishStackFsp
|
2014-07-29 04:21:52 +02:00
|
|
|
|
2015-04-23 10:52:21 +02:00
|
|
|
LXMMN xmm6, eax, 3 ;Restore microcode status if no CAR init error from ECX-SLOT 3 in xmm6.
|
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
NemInitExit:
|
|
|
|
;
|
|
|
|
; Load EBP, EBX, ESI, EDI & ESP from XMM7 & XMM6
|
|
|
|
;
|
|
|
|
LOAD_REGS
|
|
|
|
ret
|
|
|
|
TempRamInitApi ENDP
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; FspInit API
|
|
|
|
;
|
|
|
|
; This FSP API will perform the processor and chipset initialization.
|
|
|
|
; This API will not return. Instead, it transfers the control to the
|
|
|
|
; ContinuationFunc provided in the parameter.
|
|
|
|
;
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
FspInitApi PROC NEAR PUBLIC
|
2015-02-11 03:57:40 +01:00
|
|
|
mov eax, 1
|
|
|
|
jmp FspApiCommon
|
|
|
|
FspInitApi ENDP
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; NotifyPhase API
|
|
|
|
;
|
|
|
|
; This FSP API will notify the FSP about the different phases in the boot
|
|
|
|
; process
|
|
|
|
;
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
NotifyPhaseApi PROC C PUBLIC
|
|
|
|
mov eax, 2
|
|
|
|
jmp FspApiCommon
|
|
|
|
NotifyPhaseApi ENDP
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; FspMemoryInit API
|
|
|
|
;
|
|
|
|
; This FSP API is called after TempRamInit and initializes the memory.
|
|
|
|
;
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
FspMemoryInitApi PROC NEAR PUBLIC
|
|
|
|
mov eax, 3
|
|
|
|
jmp FspApiCommon
|
|
|
|
FspMemoryInitApi ENDP
|
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; TempRamExitApi API
|
|
|
|
;
|
|
|
|
; This API tears down temporary RAM
|
|
|
|
;
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
TempRamExitApi PROC C PUBLIC
|
|
|
|
mov eax, 4
|
|
|
|
jmp FspApiCommon
|
|
|
|
TempRamExitApi ENDP
|
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; FspSiliconInit API
|
|
|
|
;
|
|
|
|
; This FSP API initializes the CPU and the chipset including the IO
|
|
|
|
; controllers in the chipset to enable normal operation of these devices.
|
|
|
|
;
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
FspSiliconInitApi PROC C PUBLIC
|
|
|
|
mov eax, 5
|
|
|
|
jmp FspApiCommon
|
|
|
|
FspSiliconInitApi ENDP
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; FspApiCommon API
|
|
|
|
;
|
|
|
|
; This is the FSP API common entry point to resume the FSP execution
|
|
|
|
;
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
FspApiCommon PROC C PUBLIC
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
; EAX holds the API index
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
|
|
|
|
;
|
|
|
|
; Stack must be ready
|
|
|
|
;
|
|
|
|
push eax
|
|
|
|
add esp, 4
|
|
|
|
cmp eax, dword ptr [esp - 4]
|
2014-07-29 04:21:52 +02:00
|
|
|
jz @F
|
|
|
|
mov eax, 080000003h
|
|
|
|
jmp exit
|
|
|
|
|
|
|
|
@@:
|
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
; Verify the calling condition
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
|
|
|
pushad
|
2015-04-23 10:52:21 +02:00
|
|
|
push [esp + 4 * 8 + 4]
|
2015-02-11 03:57:40 +01:00
|
|
|
push eax
|
2014-07-29 04:21:52 +02:00
|
|
|
call FspApiCallingCheck
|
2015-04-23 10:52:21 +02:00
|
|
|
add esp, 8
|
2014-07-29 04:21:52 +02:00
|
|
|
cmp eax, 0
|
|
|
|
jz @F
|
2015-02-11 03:57:40 +01:00
|
|
|
mov dword ptr [esp + 4 * 7], eax
|
|
|
|
popad
|
|
|
|
ret
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
@@:
|
2015-02-11 03:57:40 +01:00
|
|
|
popad
|
|
|
|
cmp eax, 1 ; FspInit API
|
|
|
|
jz @F
|
|
|
|
cmp eax, 3 ; FspMemoryInit API
|
|
|
|
jz @F
|
2015-04-29 05:10:24 +02:00
|
|
|
|
|
|
|
call GetFspInfoHdr
|
|
|
|
jmp Loader2PeiSwitchStack
|
2015-02-11 03:57:40 +01:00
|
|
|
|
2015-04-23 10:52:21 +02:00
|
|
|
@@:
|
2015-02-11 03:57:40 +01:00
|
|
|
;
|
|
|
|
; FspInit and FspMemoryInit APIs, setup the initial stack frame
|
2015-04-23 10:52:21 +02:00
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
2015-04-29 05:10:24 +02:00
|
|
|
; Place holder to store the FspInfoHeader pointer
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
2015-04-29 05:10:24 +02:00
|
|
|
push eax
|
|
|
|
|
|
|
|
;
|
|
|
|
; Update the FspInfoHeader pointer
|
|
|
|
;
|
|
|
|
push eax
|
|
|
|
call GetFspInfoHdr
|
|
|
|
mov [esp + 4], eax
|
|
|
|
pop eax
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
; Create a Task Frame in the stack for the Boot Loader
|
|
|
|
;
|
|
|
|
pushfd ; 2 pushf for 4 byte alignment
|
|
|
|
cli
|
|
|
|
pushad
|
|
|
|
|
|
|
|
; Reserve 8 bytes for IDT save/restore
|
|
|
|
sub esp, 8
|
2015-04-23 10:52:21 +02:00
|
|
|
sidt fword ptr [esp]
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
; Setup new FSP stack
|
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
mov edi, esp
|
2014-07-29 04:21:52 +02:00
|
|
|
mov esp, PcdGet32(PcdTemporaryRamBase)
|
|
|
|
add esp, PcdGet32(PcdTemporaryRamSize)
|
|
|
|
sub esp, (DATA_LEN_AT_STACK_TOP + 40h)
|
|
|
|
|
|
|
|
;
|
2015-02-11 03:57:40 +01:00
|
|
|
; Pass the API Idx to SecStartup
|
2014-07-29 04:21:52 +02:00
|
|
|
;
|
|
|
|
push eax
|
2015-02-11 03:57:40 +01:00
|
|
|
|
|
|
|
;
|
2015-04-23 10:52:21 +02:00
|
|
|
; Pass the BootLoader stack to SecStartup
|
2015-02-11 03:57:40 +01:00
|
|
|
;
|
|
|
|
push edi
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
; Pass entry point of the PEI core
|
|
|
|
;
|
|
|
|
call GetFspBaseAddress
|
2015-02-11 03:57:40 +01:00
|
|
|
mov edi, eax
|
|
|
|
add edi, PcdGet32 (PcdFspAreaSize)
|
2014-07-29 04:21:52 +02:00
|
|
|
sub edi, 20h
|
2015-02-11 03:57:40 +01:00
|
|
|
add eax, DWORD PTR ds:[edi]
|
2014-07-29 04:21:52 +02:00
|
|
|
push eax
|
|
|
|
|
|
|
|
;
|
|
|
|
; Pass BFV into the PEI Core
|
|
|
|
; It uses relative address to calucate the actual boot FV base
|
|
|
|
; For FSP impleantion with single FV, PcdFlashFvRecoveryBase and
|
|
|
|
; PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs,
|
|
|
|
; they are different. The code below can handle both cases.
|
|
|
|
;
|
|
|
|
call GetFspBaseAddress
|
|
|
|
mov edi, eax
|
|
|
|
call GetBootFirmwareVolumeOffset
|
|
|
|
add eax, edi
|
|
|
|
push eax
|
|
|
|
|
|
|
|
;
|
|
|
|
; Pass stack base and size into the PEI Core
|
|
|
|
;
|
|
|
|
mov eax, PcdGet32(PcdTemporaryRamBase)
|
|
|
|
add eax, PcdGet32(PcdTemporaryRamSize)
|
|
|
|
sub eax, PcdGet32(PcdFspTemporaryRamSize)
|
|
|
|
push eax
|
|
|
|
push PcdGet32(PcdFspTemporaryRamSize)
|
|
|
|
|
|
|
|
;
|
|
|
|
; Pass Control into the PEI Core
|
|
|
|
;
|
|
|
|
call SecStartup
|
2015-04-29 05:10:24 +02:00
|
|
|
add esp, 4
|
2015-04-23 10:52:21 +02:00
|
|
|
exit:
|
2014-07-29 04:21:52 +02:00
|
|
|
ret
|
|
|
|
|
2015-02-11 03:57:40 +01:00
|
|
|
FspApiCommon ENDP
|
2014-07-29 04:21:52 +02:00
|
|
|
|
|
|
|
END
|