]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Sec/SecMain.c
Update the copyright notice format
[mirror_edk2.git] / OvmfPkg / Sec / SecMain.c
index 1dafa05025bdbae5478800fd5e54509f875ad21e..275d8e492a7292b83f10bc8045c91491e22e7b6e 100644 (file)
@@ -1,9 +1,9 @@
 /** @file
   Main SEC phase code.  Transitions to PEI.
 
-  Copyright (c) 2008 - 2009, Intel Corporation
+  Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
 
-  All rights reserved. This program and the accompanying materials
+  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
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
 #include <Library/BaseMemoryLib.h>
+#include <Library/PeimEntryPoint.h>
 #include <Library/PeiServicesLib.h>
 #include <Ppi/TemporaryRamSupport.h>
 #include <Library/PcdLib.h>
+#include <Library/UefiCpuLib.h>
 
 #include "SecMain.h"
 
@@ -60,10 +62,8 @@ InitializeIdtPtr (
 VOID
 EFIAPI
 SecCoreStartupWithStack (
-  IN VOID       *BootFirmwareVolumePtr,
-  IN VOID       *SecCoreEntryPoint,
-  IN VOID       *PeiCoreEntryPoint,
-  IN VOID       *TopOfCurrentStack
+  IN EFI_FIRMWARE_VOLUME_HEADER       *BootFv,
+  IN VOID                             *TopOfCurrentStack
   )
 {
   EFI_SEC_PEI_HAND_OFF        *SecCoreData;
@@ -71,15 +71,22 @@ SecCoreStartupWithStack (
   UINT8                       *TopOfTempRam;
   UINTN                       SizeOfTempRam;
   VOID                        *IdtPtr;
+  VOID                        *PeiCoreEntryPoint;
 
-  DEBUG ((EFI_D_ERROR,
-    "SecCoreStartupWithStack(0x%x, 0x%x, 0x%x, 0x%x)\n",
-    (UINT32)(UINTN)BootFirmwareVolumePtr,
-    (UINT32)(UINTN)SecCoreEntryPoint,
-    (UINT32)(UINTN)PeiCoreEntryPoint,
-    (UINT32)(UINTN)TopOfCurrentStack));
+  DEBUG ((EFI_D_INFO,
+    "SecCoreStartupWithStack(0x%x, 0x%x)\n",
+    (UINT32)(UINTN)BootFv,
+    (UINT32)(UINTN)TopOfCurrentStack
+    ));
+
+  ProcessLibraryConstructorList (NULL, NULL);
+
+  //
+  // Initialize floating point operating environment
+  // to be compliant with UEFI spec.
+  //
+  InitializeFloatingPointUnits ();
 
-  
   BottomOfTempRam = (UINT8*)(UINTN) INITIAL_TOP_OF_STACK;
   SizeOfTempRam = (UINTN) SIZE_64KB;
   TopOfTempRam = BottomOfTempRam + SizeOfTempRam;
@@ -100,9 +107,6 @@ SecCoreStartupWithStack (
   SecCoreData = (EFI_SEC_PEI_HAND_OFF*)((UINTN) TopOfTempRam - SIZE_4KB);
   SecCoreData->DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
 
-  SecCoreData->BootFirmwareVolumeBase = (VOID*)(UINTN) PcdGet32 (PcdOvmfFlashFvRecoveryBase);
-  SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdOvmfFlashFvRecoverySize);
-
   SecCoreData->TemporaryRamBase       = (VOID*) BottomOfTempRam;
   SecCoreData->TemporaryRamSize       = SizeOfTempRam;
 
@@ -120,20 +124,34 @@ SecCoreStartupWithStack (
   IdtPtr = ALIGN_POINTER(IdtPtr, 16);
   InitializeIdtPtr (IdtPtr);
 
-  //
-  // Transfer control to the PEI Core
-  //
-  PeiSwitchStacks (
-    (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,
-    SecCoreData,
-    (VOID *) (UINTN) ((EFI_PEI_PPI_DESCRIPTOR *) &mPrivateDispatchTable),
-    NULL,
-    TopOfCurrentStack,
-    (VOID *)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)
-    );
+  FindPeiCoreEntryPoint (&BootFv, &PeiCoreEntryPoint);
+
+  SecCoreData->BootFirmwareVolumeBase = BootFv;
+  SecCoreData->BootFirmwareVolumeSize = (UINTN) BootFv->FvLength;
+
+  if (PeiCoreEntryPoint != NULL) {
+    DEBUG ((EFI_D_INFO,
+      "Calling PEI Core entry point at 0x%x\n",
+      PeiCoreEntryPoint
+      ));
+    //
+    // Transfer control to the PEI Core
+    //
+    PeiSwitchStacks (
+      (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,
+      SecCoreData,
+      (VOID *) (UINTN) ((EFI_PEI_PPI_DESCRIPTOR *) &mPrivateDispatchTable),
+      NULL,
+      TopOfCurrentStack,
+      (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);
   CpuDeadLoop ();