mirror of https://github.com/acidanthera/audk.git
IntelFsp2Pkg: BaseFspCommonLib Support for X64
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3867 Add BaseFspCommonLib Support for X64. Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Ashraf Ali S <ashraf.ali.s@intel.com> Signed-off-by: Ted Kuo <ted.kuo@intel.com> Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
This commit is contained in:
parent
267a92fef3
commit
ec0b54849b
|
@ -217,7 +217,7 @@ FspGlobalDataInit (
|
|||
**/
|
||||
VOID
|
||||
FspDataPointerFixUp (
|
||||
IN UINT32 OffsetGap
|
||||
IN UINTN OffsetGap
|
||||
)
|
||||
{
|
||||
FSP_GLOBAL_DATA *NewFspData;
|
||||
|
|
|
@ -61,7 +61,7 @@ FspGlobalDataInit (
|
|||
**/
|
||||
VOID
|
||||
FspDataPointerFixUp (
|
||||
IN UINT32 OffsetGap
|
||||
IN UINTN OffsetGap
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct {
|
|||
UINT32 Signature;
|
||||
UINT8 Version;
|
||||
UINT8 Reserved1[3];
|
||||
UINT32 CoreStack;
|
||||
UINTN CoreStack;
|
||||
UINT32 StatusCode;
|
||||
UINT32 Reserved2[8];
|
||||
FSP_PLAT_DATA PlatformData;
|
||||
|
|
|
@ -38,7 +38,7 @@ GetFspGlobalDataPointer (
|
|||
|
||||
@retval ApiParameter FSP API first parameter passed by the bootloader.
|
||||
**/
|
||||
UINT32
|
||||
UINTN
|
||||
EFIAPI
|
||||
GetFspApiParameter (
|
||||
VOID
|
||||
|
@ -49,7 +49,7 @@ GetFspApiParameter (
|
|||
|
||||
@retval ApiParameter FSP API second parameter passed by the bootloader.
|
||||
**/
|
||||
UINT32
|
||||
UINTN
|
||||
EFIAPI
|
||||
GetFspApiParameter2 (
|
||||
VOID
|
||||
|
@ -87,7 +87,7 @@ SetFspApiParameter (
|
|||
VOID
|
||||
EFIAPI
|
||||
SetFspApiReturnStatus (
|
||||
IN UINT32 ReturnStatus
|
||||
IN UINTN ReturnStatus
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,21 +30,34 @@ typedef struct {
|
|||
UINT16 IdtrLimit;
|
||||
UINT32 IdtrBase;
|
||||
UINT16 Reserved;
|
||||
UINT32 Edi;
|
||||
UINT32 Esi;
|
||||
UINT32 Ebp;
|
||||
UINT32 Esp;
|
||||
UINT32 Ebx;
|
||||
UINT32 Edx;
|
||||
UINT32 Ecx;
|
||||
UINT32 Eax;
|
||||
UINT32 Registers[8]; // General Purpose Registers: Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx and Eax
|
||||
UINT16 Flags[2];
|
||||
UINT32 FspInfoHeader;
|
||||
UINT32 ApiRet;
|
||||
UINT32 ApiParam[2];
|
||||
} CONTEXT_STACK;
|
||||
|
||||
#define CONTEXT_STACK_OFFSET(x) (UINT32)&((CONTEXT_STACK *)(UINTN)0)->x
|
||||
//
|
||||
// API return address +0xB0
|
||||
// push API Parameter2 +0xA8
|
||||
// push API Parameter1 +0xA0
|
||||
// push FspInfoHeader +0x98
|
||||
// pushfq +0x90
|
||||
// cli
|
||||
// PUSHA_64 +0x10
|
||||
// sub rsp, 16 +0x00
|
||||
// sidt [rsp]
|
||||
//
|
||||
typedef struct {
|
||||
UINT64 Idtr[2]; // IDTR Limit - bit0:bi15, IDTR Base - bit16:bit79
|
||||
UINT64 Registers[16]; // General Purpose Registers: RDI, RSI, RBP, RSP, RBX, RDX, RCX, RAX, and R15 to R8
|
||||
UINT32 Flags[2];
|
||||
UINT64 FspInfoHeader;
|
||||
UINT64 ApiParam[2];
|
||||
UINT64 ApiRet; // 64bit stack format is different from the 32bit one due to x64 calling convention
|
||||
} CONTEXT_STACK_64;
|
||||
|
||||
#define CONTEXT_STACK_OFFSET(x) (sizeof(UINTN) == sizeof (UINT32) ? (UINTN)&((CONTEXT_STACK *)(UINTN)0)->x : (UINTN)&((CONTEXT_STACK_64 *)(UINTN)0)->x)
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
@ -85,7 +98,7 @@ GetFspGlobalDataPointer (
|
|||
|
||||
@retval ApiParameter FSP API first parameter passed by the bootloader.
|
||||
**/
|
||||
UINT32
|
||||
UINTN
|
||||
EFIAPI
|
||||
GetFspApiParameter (
|
||||
VOID
|
||||
|
@ -94,7 +107,7 @@ GetFspApiParameter (
|
|||
FSP_GLOBAL_DATA *FspData;
|
||||
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
return *(UINT32 *)(UINTN)(FspData->CoreStack + CONTEXT_STACK_OFFSET (ApiParam[0]));
|
||||
return *(UINTN *)(FspData->CoreStack + CONTEXT_STACK_OFFSET (ApiParam[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +132,7 @@ GetFspEntryStack (
|
|||
|
||||
@retval ApiParameter FSP API second parameter passed by the bootloader.
|
||||
**/
|
||||
UINT32
|
||||
UINTN
|
||||
EFIAPI
|
||||
GetFspApiParameter2 (
|
||||
VOID
|
||||
|
@ -128,7 +141,7 @@ GetFspApiParameter2 (
|
|||
FSP_GLOBAL_DATA *FspData;
|
||||
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
return *(UINT32 *)(UINTN)(FspData->CoreStack + CONTEXT_STACK_OFFSET (ApiParam[1]));
|
||||
return *(UINTN *)(FspData->CoreStack + CONTEXT_STACK_OFFSET (ApiParam[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,8 +158,8 @@ SetFspApiParameter (
|
|||
{
|
||||
FSP_GLOBAL_DATA *FspData;
|
||||
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
*(UINT32 *)(UINTN)(FspData->CoreStack + CONTEXT_STACK_OFFSET (ApiParam)) = Value;
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
*(UINTN *)(FspData->CoreStack + CONTEXT_STACK_OFFSET (ApiParam)) = Value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,13 +171,13 @@ SetFspApiParameter (
|
|||
VOID
|
||||
EFIAPI
|
||||
SetFspApiReturnStatus (
|
||||
IN UINT32 ReturnStatus
|
||||
IN UINTN ReturnStatus
|
||||
)
|
||||
{
|
||||
FSP_GLOBAL_DATA *FspData;
|
||||
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
*(UINT32 *)(UINTN)(FspData->CoreStack + CONTEXT_STACK_OFFSET (Eax)) = ReturnStatus;
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
*(UINTN *)(FspData->CoreStack + CONTEXT_STACK_OFFSET (Registers[7])) = ReturnStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,19 +193,19 @@ SetFspCoreStackPointer (
|
|||
)
|
||||
{
|
||||
FSP_GLOBAL_DATA *FspData;
|
||||
UINT32 *OldStack;
|
||||
UINT32 *NewStack;
|
||||
UINTN *OldStack;
|
||||
UINTN *NewStack;
|
||||
UINT32 StackContextLen;
|
||||
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
StackContextLen = sizeof (CONTEXT_STACK) / sizeof (UINT32);
|
||||
StackContextLen = sizeof(CONTEXT_STACK) / sizeof(UINTN);
|
||||
|
||||
//
|
||||
// Reserve space for the ContinuationFunc two parameters
|
||||
//
|
||||
OldStack = (UINT32 *)FspData->CoreStack;
|
||||
NewStack = (UINT32 *)NewStackTop - StackContextLen - 2;
|
||||
FspData->CoreStack = (UINT32)NewStack;
|
||||
OldStack = (UINTN *)FspData->CoreStack;
|
||||
NewStack = (UINTN *)NewStackTop - StackContextLen - 2;
|
||||
FspData->CoreStack = (UINTN)NewStack;
|
||||
while (StackContextLen-- != 0) {
|
||||
*NewStack++ = *OldStack++;
|
||||
}
|
||||
|
@ -427,7 +440,7 @@ GetFspInfoHeaderFromApiContext (
|
|||
FSP_GLOBAL_DATA *FspData;
|
||||
|
||||
FspData = GetFspGlobalDataPointer ();
|
||||
return (FSP_INFO_HEADER *)(*(UINT32 *)(UINTN)(FspData->CoreStack + CONTEXT_STACK_OFFSET (FspInfoHeader)));
|
||||
return (FSP_INFO_HEADER *)(*(UINTN *)(FspData->CoreStack + CONTEXT_STACK_OFFSET (FspInfoHeader)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -444,7 +457,7 @@ GetFspCfgRegionDataPointer (
|
|||
FSP_INFO_HEADER *FspInfoHeader;
|
||||
|
||||
FspInfoHeader = GetFspInfoHeader ();
|
||||
return (VOID *)(FspInfoHeader->ImageBase + FspInfoHeader->CfgRegionOffset);
|
||||
return (VOID *)(UINTN)(FspInfoHeader->ImageBase + FspInfoHeader->CfgRegionOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue