mirror of https://github.com/acidanthera/audk.git
OVMF SEC: Modify to match new interface of reset vector module
Previously the interface to the SEC module was: ESI/RSI - SEC Core entry point EDI/RDI - PEI Core entry point EBP/RBP - Start of BFV Now it is: RAX/EAX Initial value of the EAX register (BIST: Built-in Self Test) DI 'BP': boot-strap processor, or 'AP': application processor RBP/EBP Address of Boot Firmware Volume (BFV) git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9572 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
7a55c43b07
commit
0913fadc1a
|
@ -0,0 +1,103 @@
|
||||||
|
/** @file
|
||||||
|
Locate the entry point for the PEI Core
|
||||||
|
|
||||||
|
Copyright (c) 2008 - 2009, Intel Corporation
|
||||||
|
|
||||||
|
All rights reserved. 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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiPei.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PeCoffGetEntryPointLib.h>
|
||||||
|
|
||||||
|
#include "SecMain.h"
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
FindPeiCoreEntryPoint (
|
||||||
|
IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr,
|
||||||
|
OUT VOID **PeiCoreEntryPoint
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_PHYSICAL_ADDRESS CurrentAddress;
|
||||||
|
EFI_PHYSICAL_ADDRESS EndOfFirmwareVolume;
|
||||||
|
EFI_FFS_FILE_HEADER *File;
|
||||||
|
UINT32 Size;
|
||||||
|
EFI_PHYSICAL_ADDRESS EndOfFile;
|
||||||
|
EFI_COMMON_SECTION_HEADER *Section;
|
||||||
|
EFI_PHYSICAL_ADDRESS EndOfSection;
|
||||||
|
|
||||||
|
*PeiCoreEntryPoint = NULL;
|
||||||
|
|
||||||
|
CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) BootFirmwareVolumePtr;
|
||||||
|
EndOfFirmwareVolume = CurrentAddress + BootFirmwareVolumePtr->FvLength;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Loop through the FFS files in the Boot Firmware Volume
|
||||||
|
//
|
||||||
|
for (EndOfFile = CurrentAddress + BootFirmwareVolumePtr->HeaderLength; ; ) {
|
||||||
|
|
||||||
|
CurrentAddress = (EndOfFile + 7) & 0xfffffffffffffff8ULL;
|
||||||
|
if (CurrentAddress > EndOfFirmwareVolume) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress;
|
||||||
|
Size = *(UINT32*) File->Size & 0xffffff;
|
||||||
|
if (Size < (sizeof (*File) + sizeof (*Section))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EndOfFile = CurrentAddress + Size;
|
||||||
|
if (EndOfFile > EndOfFirmwareVolume) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Look for PEI Core files
|
||||||
|
//
|
||||||
|
if (File->Type != EFI_FV_FILETYPE_PEI_CORE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Loop through the FFS file sections within the PEI Core FFS file
|
||||||
|
//
|
||||||
|
EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN) (File + 1);
|
||||||
|
for (;;) {
|
||||||
|
CurrentAddress = (EndOfSection + 3) & 0xfffffffffffffffcULL;
|
||||||
|
Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress;
|
||||||
|
|
||||||
|
Size = *(UINT32*) Section->Size & 0xffffff;
|
||||||
|
if (Size < sizeof (*Section)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EndOfSection = CurrentAddress + Size;
|
||||||
|
if (EndOfSection > EndOfFile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Look for executable sections
|
||||||
|
//
|
||||||
|
if (Section->Type == EFI_SECTION_PE32) {
|
||||||
|
Status = PeCoffLoaderGetEntryPoint ((VOID*) (Section + 1), PeiCoreEntryPoint);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
#
|
|
||||||
# ConvertAsm.py: Automatically generated from SecEntry.asm
|
|
||||||
#
|
|
||||||
# TITLE SecEntry.asm
|
# TITLE SecEntry.asm
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
#*
|
#*
|
||||||
#* Copyright 2006 - 2009, Intel Corporation
|
#* Copyright 2006 - 2009, Intel Corporation
|
||||||
|
@ -30,12 +26,11 @@
|
||||||
#
|
#
|
||||||
# Processor is in flat protected mode
|
# Processor is in flat protected mode
|
||||||
#
|
#
|
||||||
# @param ESI Pointer to SEC Core Entry Point (this function)
|
# @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test)
|
||||||
# @param EDI Pointer to PEI Core Entry Point
|
# @param[in] DI 'BP': boot-strap processor, or 'AP': application processor
|
||||||
# @param EBP Pointer to the start of the Boot Firmware Volume
|
# @param[in] EBP Pointer to the start of the Boot Firmware Volume
|
||||||
#
|
|
||||||
# @return None
|
|
||||||
#
|
#
|
||||||
|
# @return None This routine does not return
|
||||||
#
|
#
|
||||||
ASM_GLOBAL ASM_PFX(_ModuleEntryPoint)
|
ASM_GLOBAL ASM_PFX(_ModuleEntryPoint)
|
||||||
ASM_PFX(_ModuleEntryPoint):
|
ASM_PFX(_ModuleEntryPoint):
|
||||||
|
@ -52,8 +47,6 @@ ASM_PFX(_ModuleEntryPoint):
|
||||||
# Call into C code
|
# Call into C code
|
||||||
#
|
#
|
||||||
pushl %eax
|
pushl %eax
|
||||||
pushl %edi
|
|
||||||
pushl %esi
|
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
call ASM_PFX(SecCoreStartupWithStack)
|
call ASM_PFX(SecCoreStartupWithStack)
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,11 @@ EXTERN SecCoreStartupWithStack:PROC
|
||||||
;
|
;
|
||||||
; Processor is in flat protected mode
|
; Processor is in flat protected mode
|
||||||
;
|
;
|
||||||
; @param ESI Pointer to SEC Core Entry Point (this function)
|
; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test)
|
||||||
; @param EDI Pointer to PEI Core Entry Point
|
; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor
|
||||||
; @param EBP Pointer to the start of the Boot Firmware Volume
|
; @param[in] EBP Pointer to the start of the Boot Firmware Volume
|
||||||
;
|
|
||||||
; @return None
|
|
||||||
;
|
;
|
||||||
|
; @return None This routine does not return
|
||||||
;
|
;
|
||||||
_ModuleEntryPoint PROC PUBLIC
|
_ModuleEntryPoint PROC PUBLIC
|
||||||
|
|
||||||
|
@ -50,8 +49,6 @@ _ModuleEntryPoint PROC PUBLIC
|
||||||
; Call into C code
|
; Call into C code
|
||||||
;
|
;
|
||||||
push eax
|
push eax
|
||||||
push edi
|
|
||||||
push esi
|
|
||||||
push ebp
|
push ebp
|
||||||
call SecCoreStartupWithStack
|
call SecCoreStartupWithStack
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,7 @@ InitializeIdtPtr (
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SecCoreStartupWithStack (
|
SecCoreStartupWithStack (
|
||||||
IN VOID *BootFirmwareVolumePtr,
|
IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr,
|
||||||
IN VOID *SecCoreEntryPoint,
|
|
||||||
IN VOID *PeiCoreEntryPoint,
|
|
||||||
IN VOID *TopOfCurrentStack
|
IN VOID *TopOfCurrentStack
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -72,6 +70,7 @@ SecCoreStartupWithStack (
|
||||||
UINT8 *TopOfTempRam;
|
UINT8 *TopOfTempRam;
|
||||||
UINTN SizeOfTempRam;
|
UINTN SizeOfTempRam;
|
||||||
VOID *IdtPtr;
|
VOID *IdtPtr;
|
||||||
|
VOID *PeiCoreEntryPoint;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize floating point operating environment
|
// Initialize floating point operating environment
|
||||||
|
@ -79,13 +78,11 @@ SecCoreStartupWithStack (
|
||||||
//
|
//
|
||||||
InitializeFloatingPointUnits ();
|
InitializeFloatingPointUnits ();
|
||||||
|
|
||||||
DEBUG ((EFI_D_ERROR,
|
DEBUG ((EFI_D_INFO,
|
||||||
"SecCoreStartupWithStack(0x%x, 0x%x, 0x%x, 0x%x)\n",
|
"SecCoreStartupWithStack(0x%x, 0x%x)\n",
|
||||||
(UINT32)(UINTN)BootFirmwareVolumePtr,
|
(UINT32)(UINTN)BootFirmwareVolumePtr,
|
||||||
(UINT32)(UINTN)SecCoreEntryPoint,
|
(UINT32)(UINTN)TopOfCurrentStack
|
||||||
(UINT32)(UINTN)PeiCoreEntryPoint,
|
));
|
||||||
(UINT32)(UINTN)TopOfCurrentStack));
|
|
||||||
|
|
||||||
|
|
||||||
BottomOfTempRam = (UINT8*)(UINTN) INITIAL_TOP_OF_STACK;
|
BottomOfTempRam = (UINT8*)(UINTN) INITIAL_TOP_OF_STACK;
|
||||||
SizeOfTempRam = (UINTN) SIZE_64KB;
|
SizeOfTempRam = (UINTN) SIZE_64KB;
|
||||||
|
@ -127,6 +124,13 @@ SecCoreStartupWithStack (
|
||||||
IdtPtr = ALIGN_POINTER(IdtPtr, 16);
|
IdtPtr = ALIGN_POINTER(IdtPtr, 16);
|
||||||
InitializeIdtPtr (IdtPtr);
|
InitializeIdtPtr (IdtPtr);
|
||||||
|
|
||||||
|
FindPeiCoreEntryPoint (BootFirmwareVolumePtr, &PeiCoreEntryPoint);
|
||||||
|
|
||||||
|
if (PeiCoreEntryPoint != NULL) {
|
||||||
|
DEBUG ((EFI_D_INFO,
|
||||||
|
"Calling PEI Core entry point at 0x%x\n",
|
||||||
|
PeiCoreEntryPoint
|
||||||
|
));
|
||||||
//
|
//
|
||||||
// Transfer control to the PEI Core
|
// Transfer control to the PEI Core
|
||||||
//
|
//
|
||||||
|
@ -138,9 +142,13 @@ SecCoreStartupWithStack (
|
||||||
TopOfCurrentStack,
|
TopOfCurrentStack,
|
||||||
(VOID *)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)
|
(VOID *)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we get here, then the PEI Core returned. This is an error
|
// If we get here, then either we couldn't locate the PEI Core, or
|
||||||
|
// the PEI Core returned.
|
||||||
|
//
|
||||||
|
// Both of these errors are unrecoverable.
|
||||||
//
|
//
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
|
|
|
@ -44,6 +44,13 @@ TemporaryRamMigration (
|
||||||
IN UINTN CopySize
|
IN UINTN CopySize
|
||||||
);
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
FindPeiCoreEntryPoint (
|
||||||
|
IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr,
|
||||||
|
OUT VOID **PeiCoreEntryPoint
|
||||||
|
);
|
||||||
|
|
||||||
#define INITIAL_TOP_OF_STACK BASE_128KB
|
#define INITIAL_TOP_OF_STACK BASE_128KB
|
||||||
|
|
||||||
#endif // _PLATFORM_SECMAIN_H_
|
#endif // _PLATFORM_SECMAIN_H_
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#/** @file
|
#/** @file
|
||||||
# SEC Driver
|
# SEC Driver
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008, Intel Corporation
|
# Copyright (c) 2008 - 2009, Intel Corporation
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
[Sources.common]
|
[Sources.common]
|
||||||
|
FindPeiCore.c
|
||||||
SecMain.c
|
SecMain.c
|
||||||
|
|
||||||
[Sources.IA32]
|
[Sources.IA32]
|
||||||
|
@ -49,8 +50,9 @@
|
||||||
|
|
||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
BaseLib
|
BaseLib
|
||||||
UefiCpuLib
|
|
||||||
PcdLib
|
PcdLib
|
||||||
|
PeCoffGetEntryPointLib
|
||||||
|
UefiCpuLib
|
||||||
|
|
||||||
[Ppis]
|
[Ppis]
|
||||||
gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED
|
gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# TITLE SecEntry.asm
|
# TITLE SecEntry.asm
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
#*
|
#*
|
||||||
#* Copyright 2006 - 2009, Intel Corporation
|
#* Copyright 2006 - 2009, Intel Corporation
|
||||||
|
@ -27,12 +26,11 @@
|
||||||
#
|
#
|
||||||
# Processor is in flat protected mode
|
# Processor is in flat protected mode
|
||||||
#
|
#
|
||||||
# @param ESI Pointer to SEC Core Entry Point (this function)
|
# @param[in] RAX Initial value of the EAX register (BIST: Built-in Self Test)
|
||||||
# @param EDI Pointer to PEI Core Entry Point
|
# @param[in] DI 'BP': boot-strap processor, or 'AP': application processor
|
||||||
# @param EBP Pointer to the start of the Boot Firmware Volume
|
# @param[in] RBP Pointer to the start of the Boot Firmware Volume
|
||||||
#
|
|
||||||
# @return None
|
|
||||||
#
|
#
|
||||||
|
# @return None This routine does not return
|
||||||
#
|
#
|
||||||
ASM_GLOBAL ASM_PFX(_ModuleEntryPoint)
|
ASM_GLOBAL ASM_PFX(_ModuleEntryPoint)
|
||||||
ASM_PFX(_ModuleEntryPoint):
|
ASM_PFX(_ModuleEntryPoint):
|
||||||
|
@ -47,14 +45,10 @@ ASM_PFX(_ModuleEntryPoint):
|
||||||
#
|
#
|
||||||
# Setup parameters and call SecCoreStartupWithStack
|
# Setup parameters and call SecCoreStartupWithStack
|
||||||
# rcx: BootFirmwareVolumePtr
|
# rcx: BootFirmwareVolumePtr
|
||||||
# rdx: SecCoreEntryPoint
|
# rdx: TopOfCurrentStack
|
||||||
# r8: PeiCoreEntryPoint
|
|
||||||
# r9: TopOfCurrentStack
|
|
||||||
#
|
#
|
||||||
movq %rbp, %rcx
|
movq %rbp, %rcx
|
||||||
movq %rsi, %rdx
|
movq %rsp, %rdx
|
||||||
movq %rdi, %r8
|
|
||||||
movq %rsp, %r9
|
|
||||||
subq $0x20, %rsp
|
subq $0x20, %rsp
|
||||||
call ASM_PFX(SecCoreStartupWithStack)
|
call ASM_PFX(SecCoreStartupWithStack)
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,11 @@ EXTERN SecCoreStartupWithStack:PROC
|
||||||
;
|
;
|
||||||
; Processor is in flat protected mode
|
; Processor is in flat protected mode
|
||||||
;
|
;
|
||||||
; @param ESI Pointer to SEC Core Entry Point (this function)
|
; @param[in] RAX Initial value of the EAX register (BIST: Built-in Self Test)
|
||||||
; @param EDI Pointer to PEI Core Entry Point
|
; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor
|
||||||
; @param EBP Pointer to the start of the Boot Firmware Volume
|
; @param[in] RBP Pointer to the start of the Boot Firmware Volume
|
||||||
;
|
|
||||||
; @return None
|
|
||||||
;
|
;
|
||||||
|
; @return None This routine does not return
|
||||||
;
|
;
|
||||||
_ModuleEntryPoint PROC PUBLIC
|
_ModuleEntryPoint PROC PUBLIC
|
||||||
|
|
||||||
|
@ -46,14 +45,10 @@ _ModuleEntryPoint PROC PUBLIC
|
||||||
;
|
;
|
||||||
; Setup parameters and call SecCoreStartupWithStack
|
; Setup parameters and call SecCoreStartupWithStack
|
||||||
; rcx: BootFirmwareVolumePtr
|
; rcx: BootFirmwareVolumePtr
|
||||||
; rdx: SecCoreEntryPoint
|
; rdx: TopOfCurrentStack
|
||||||
; r8: PeiCoreEntryPoint
|
|
||||||
; r9: TopOfCurrentStack
|
|
||||||
;
|
;
|
||||||
mov rcx, rbp
|
mov rcx, rbp
|
||||||
mov rdx, rsi
|
mov rdx, rsp
|
||||||
mov r8, rdi
|
|
||||||
mov r9, rsp
|
|
||||||
sub rsp, 20h
|
sub rsp, 20h
|
||||||
call SecCoreStartupWithStack
|
call SecCoreStartupWithStack
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue