IntelFspPkg/FspSecCore add AsmGetFspBaseAddressNoStack and AsmGetFspInfoHeaderNoStack

Fix GCC issue on FspInfoHeaderRelativeOff.
Clean up comments for platform ID matching on Microcode and PcdFspBootFirmwareVolumeBase

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <Jiewen.Yao@intel.com>
Reviewed-by: "Rangarajan, Ravi P" <ravi.p.rangarajan@intel.com>
Reviewed-by: "Mudusuru, Giri P" <giri.p.mudusuru@intel.com>
Reviewed-by: "Ma, Maurice" <maurice.ma@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17496 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Yao, Jiewen 2015-05-22 07:49:34 +00:00 committed by jyao1
parent e7401ee1af
commit f0abe42fd7
4 changed files with 76 additions and 9 deletions

View File

@ -143,8 +143,8 @@ check_main_header:
mov ecx, MSR_IA32_PLATFORM_ID mov ecx, MSR_IA32_PLATFORM_ID
rdmsr rdmsr
mov ecx, edx mov ecx, edx
shr ecx, 50-32 shr ecx, 50-32 ; shift (50d-32d=18d=0x12) bits
and ecx, 7h and ecx, 7h ; platform id at bit[52..50]
mov edx, 1 mov edx, 1
shl edx, cl shl edx, cl
@ -569,7 +569,7 @@ FspApiCommon PROC C PUBLIC
; ;
; Pass BFV into the PEI Core ; Pass BFV into the PEI Core
; It uses relative address to calucate the actual boot FV base ; It uses relative address to calucate the actual boot FV base
; For FSP impleantion with single FV, PcdFlashFvRecoveryBase and ; For FSP implementation with single FV, PcdFspBootFirmwareVolumeBase and
; PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs, ; PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs,
; they are different. The code below can handle both cases. ; they are different. The code below can handle both cases.
; ;

View File

@ -297,8 +297,8 @@ CheckMainHeader:
movl $MSR_IA32_PLATFORM_ID, %ecx movl $MSR_IA32_PLATFORM_ID, %ecx
rdmsr rdmsr
movl %edx, %ecx movl %edx, %ecx
shrl $0x12, %ecx #($50-$32) shrl $0x12, %ecx # shift (50d-32d=18d=0x12) bits
andl $0x07, %ecx andl $0x07, %ecx # platform id at bit[52..50]
movl $0x01, %edx movl $0x01, %edx
shll %cl,%edx shll %cl,%edx
@ -784,7 +784,7 @@ FspApiCommonL2:
# #
# Pass BFV into the PEI Core # Pass BFV into the PEI Core
# It uses relative address to calucate the actual boot FV base # It uses relative address to calucate the actual boot FV base
# For FSP impleantion with single FV, PcdFlashFvRecoveryBase and # For FSP implementation with single FV, PcdFspBootFirmwareVolumeBase and
# PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs, # PcdFspAreaBaseAddress are the same. For FSP with mulitple FVs,
# they are different. The code below can handle both cases. # they are different. The code below can handle both cases.
# #

View File

@ -15,6 +15,10 @@
.model flat,C .model flat,C
.code .code
;
; FspInfoHeaderRelativeOff is patched during build process and initialized to offset of the AsmGetFspBaseAddress
; from the FSP Info header.
;
FspInfoHeaderRelativeOff PROC NEAR PUBLIC FspInfoHeaderRelativeOff PROC NEAR PUBLIC
; ;
; This value will be pached by the build script ; This value will be pached by the build script
@ -22,6 +26,11 @@ FspInfoHeaderRelativeOff PROC NEAR PUBLIC
DD 012345678h DD 012345678h
FspInfoHeaderRelativeOff ENDP FspInfoHeaderRelativeOff ENDP
;
; Returns FSP Base Address.
;
; This function gets the FSP Info Header using relative addressing and returns the FSP Base from the header structure
;
AsmGetFspBaseAddress PROC NEAR PUBLIC AsmGetFspBaseAddress PROC NEAR PUBLIC
mov eax, AsmGetFspBaseAddress mov eax, AsmGetFspBaseAddress
sub eax, dword ptr [FspInfoHeaderRelativeOff] sub eax, dword ptr [FspInfoHeaderRelativeOff]
@ -30,10 +39,35 @@ AsmGetFspBaseAddress PROC NEAR PUBLIC
ret ret
AsmGetFspBaseAddress ENDP AsmGetFspBaseAddress ENDP
;
; No stack counter part of AsmGetFspBaseAddress. Return address is in edi.
;
AsmGetFspBaseAddressNoStack PROC NEAR PUBLIC
mov eax, AsmGetFspBaseAddress
sub eax, dword ptr [FspInfoHeaderRelativeOff]
add eax, 01Ch
mov eax, dword ptr [eax]
jmp edi
AsmGetFspBaseAddressNoStack ENDP
;
; Returns FSP Info Header.
;
; This function gets the FSP Info Header using relative addressing and returns it
;
AsmGetFspInfoHeader PROC NEAR PUBLIC AsmGetFspInfoHeader PROC NEAR PUBLIC
mov eax, AsmGetFspBaseAddress mov eax, AsmGetFspBaseAddress
sub eax, dword ptr [FspInfoHeaderRelativeOff] sub eax, dword ptr [FspInfoHeaderRelativeOff]
ret ret
AsmGetFspInfoHeader ENDP AsmGetFspInfoHeader ENDP
;
; No stack counter part of AsmGetFspInfoHeader. Return address is in edi.
;
AsmGetFspInfoHeaderNoStack PROC NEAR PUBLIC
mov eax, AsmGetFspBaseAddress
sub eax, dword ptr [FspInfoHeaderRelativeOff]
jmp edi
AsmGetFspInfoHeaderNoStack ENDP
END END

View File

@ -15,6 +15,10 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#
# FspInfoHeaderRelativeOff is patched during build process and initialized to offset of the AsmGetFspBaseAddress
# from the FSP Info header.
#
ASM_GLOBAL ASM_PFX(FspInfoHeaderRelativeOff) ASM_GLOBAL ASM_PFX(FspInfoHeaderRelativeOff)
ASM_PFX(FspInfoHeaderRelativeOff): ASM_PFX(FspInfoHeaderRelativeOff):
# #
@ -22,17 +26,46 @@ ASM_PFX(FspInfoHeaderRelativeOff):
# #
.long 0x012345678 .long 0x012345678
#
# Returns FSP Base Address.
#
# This function gets the FSP Info Header using relative addressing and returns the FSP Base from the header structure
#
ASM_GLOBAL ASM_PFX(AsmGetFspBaseAddress) ASM_GLOBAL ASM_PFX(AsmGetFspBaseAddress)
ASM_PFX(AsmGetFspBaseAddress): ASM_PFX(AsmGetFspBaseAddress):
mov $AsmGetFspBaseAddress, %eax mov $AsmGetFspBaseAddress, %eax
sub $FspInfoHeaderRelativeOff, %eax sub FspInfoHeaderRelativeOff, %eax
add $0x01C, %eax add $0x01C, %eax
mov (%eax), %eax mov (%eax), %eax
ret ret
#
# No stack counter part of AsmGetFspBaseAddress. Return address is in edi.
#
ASM_GLOBAL ASM_PFX(AsmGetFspBaseAddressNoStack)
ASM_PFX(AsmGetFspBaseAddressNoStack):
mov $AsmGetFspBaseAddress, %eax
sub FspInfoHeaderRelativeOff, %eax
add $0x01C, %eax
mov (%eax), %eax
jmp *%edi
#
# Returns FSP Info Header.
#
# This function gets the FSP Info Header using relative addressing and returns it
#
ASM_GLOBAL ASM_PFX(AsmGetFspInfoHeader) ASM_GLOBAL ASM_PFX(AsmGetFspInfoHeader)
ASM_PFX(AsmGetFspInfoHeader): ASM_PFX(AsmGetFspInfoHeader):
mov $AsmGetFspBaseAddress, %eax mov $AsmGetFspBaseAddress, %eax
sub $FspInfoHeaderRelativeOff, %eax sub FspInfoHeaderRelativeOff, %eax
ret ret
#
# No stack counter part of AsmGetFspInfoHeader. Return address is in edi.
#
ASM_GLOBAL ASM_PFX(AsmGetFspInfoHeaderNoStack)
ASM_PFX(AsmGetFspInfoHeaderNoStack):
mov $AsmGetFspBaseAddress, %eax
sub FspInfoHeaderRelativeOff, %eax
jmp *%edi