]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspWrapperPkg/FspInitPei/FspInitPei.c
Update IntelFspWrapperPkg according to FSP1.1.
[mirror_edk2.git] / IntelFspWrapperPkg / FspInitPei / FspInitPei.c
index 823f1bbef8664cbf5efa87115772e4d4f8c05ac1..17a646836ab770e5426baf8201565c0b95e061f6 100644 (file)
@@ -1,9 +1,7 @@
 /** @file\r
-  This PEIM will be invoked twice by pei core. In 1st entry, it will call FspInit API.\r
-  In 2nd entry, it will parse the hoblist from fsp and report them into pei core.\r
-  This file contains the main entrypoint of the PEIM.\r
+  This PEIM initialize FSP.\r
 \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 \r
 #include "FspInitPei.h"\r
 \r
-/**\r
-  FSP Init continuation function.\r
-  Control will be returned to this callback function after FspInit API call.\r
-\r
-  @param[in] Status      Status of the FSP INIT API\r
-  @param[in] HobListPtr  Pointer to the HOB data structure defined in the PI specification.\r
-\r
-**/\r
-VOID\r
-ContinuationFunc (\r
-  IN FSP_STATUS Status,\r
-  IN VOID       *HobListPtr\r
-  )\r
-{\r
-  EFI_BOOT_MODE             BootMode;\r
-  UINT64                    StackSize;\r
-  EFI_PHYSICAL_ADDRESS      StackBase;\r
-\r
-  DEBUG ((DEBUG_INFO, "ContinuationFunc - %r\n", Status));\r
-  DEBUG ((DEBUG_INFO, "HobListPtr - 0x%x\n", HobListPtr));\r
-\r
-  if (Status != FSP_SUCCESS) {\r
-    CpuDeadLoop ();\r
-  }\r
-\r
-  //\r
-  // Can not call any PeiServices\r
-  //\r
-  BootMode = GetBootMode ();\r
-\r
-  GetStackInfo (BootMode, TRUE, &StackBase, &StackSize);\r
-  DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));\r
-  DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));\r
-  CallPeiCoreEntryPoint (\r
-    HobListPtr,\r
-    (VOID *)(UINTN)StackBase,\r
-    (VOID *)(UINTN)(StackBase + StackSize)\r
-    );\r
-}\r
-\r
-/**\r
-  Call FspInit API.\r
-\r
-  @param[in] FspHeader FSP header pointer.\r
-**/\r
-VOID\r
-SecFspInit (\r
-  IN FSP_INFO_HEADER *FspHeader\r
-  )\r
-{\r
-  FSP_INIT_PARAMS           FspInitParams;\r
-  FSP_INIT_RT_COMMON_BUFFER FspRtBuffer;\r
-  UINT8                     FspUpdRgn[FixedPcdGet32 (PcdMaxUpdRegionSize)];\r
-  UINT32                    UpdRegionSize;\r
-  EFI_BOOT_MODE             BootMode;\r
-  UINT64                    StackSize;\r
-  EFI_PHYSICAL_ADDRESS      StackBase;\r
-  FSP_STATUS                FspStatus;\r
-\r
-  DEBUG ((DEBUG_INFO, "SecFspInit enter\n"));\r
-\r
-  PeiServicesGetBootMode (&BootMode);\r
-  DEBUG ((DEBUG_INFO, "BootMode - 0x%x\n", BootMode));\r
-\r
-  GetStackInfo (BootMode, FALSE, &StackBase, &StackSize);\r
-  DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));\r
-  DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));\r
-\r
-  ZeroMem (&FspRtBuffer, sizeof(FspRtBuffer));\r
-  FspRtBuffer.StackTop = (UINT32 *)(UINTN)(StackBase + StackSize);\r
-\r
-  FspRtBuffer.BootMode = BootMode;\r
-\r
-  /* Platform override any UPD configs */\r
-  UpdRegionSize = GetUpdRegionSize();\r
-  DEBUG ((DEBUG_INFO, "UpdRegionSize - 0x%x\n", UpdRegionSize));\r
-  DEBUG ((DEBUG_INFO, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn)));\r
-  ASSERT(sizeof(FspUpdRgn) >= UpdRegionSize);\r
-  ZeroMem (FspUpdRgn, UpdRegionSize);\r
-  FspRtBuffer.UpdDataRgnPtr = UpdateFspUpdConfigs (FspUpdRgn);\r
-\r
-  ZeroMem (&FspInitParams, sizeof(FspInitParams));\r
-  FspInitParams.NvsBufferPtr = GetNvsBuffer ();\r
-  DEBUG ((DEBUG_INFO, "NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));\r
-  FspInitParams.RtBufferPtr  = (VOID *)&FspRtBuffer;\r
-  FspInitParams.ContinuationFunc = (CONTINUATION_PROC)ContinuationFunc;\r
-\r
-  SaveSecContext (GetPeiServicesTablePointer ());\r
-\r
-  DEBUG ((DEBUG_INFO, "FspInitParams      - 0x%x\n", &FspInitParams));\r
-  DEBUG ((DEBUG_INFO, "  NvsBufferPtr     - 0x%x\n", FspInitParams.NvsBufferPtr));\r
-  DEBUG ((DEBUG_INFO, "  RtBufferPtr      - 0x%x\n", FspInitParams.RtBufferPtr));\r
-  DEBUG ((DEBUG_INFO, "    StackTop       - 0x%x\n", FspRtBuffer.StackTop));\r
-  DEBUG ((DEBUG_INFO, "    BootMode       - 0x%x\n", FspRtBuffer.BootMode));\r
-  DEBUG ((DEBUG_INFO, "    UpdDataRgnPtr  - 0x%x\n", FspRtBuffer.UpdDataRgnPtr));\r
-  DEBUG ((DEBUG_INFO, "  ContinuationFunc - 0x%x\n", FspInitParams.ContinuationFunc));\r
-\r
-  FspStatus = CallFspInit (FspHeader, &FspInitParams);\r
-  //\r
-  // Should never return\r
-  //\r
-  DEBUG((DEBUG_ERROR, "FSP Init failed, status: 0x%x\n", FspStatus));\r
-  CpuDeadLoop ();\r
-}\r
-\r
 /**\r
   This is the entrypoint of PEIM\r
 \r
@@ -138,50 +31,31 @@ FspPeiEntryPoint (
   )\r
 {\r
   FSP_INFO_HEADER      *FspHeader;\r
-  EFI_STATUS           Status;\r
-  FSP_INIT_DONE_PPI    *FspInitDone;\r
-  VOID                 *FspHobList;\r
-  EFI_BOOT_MODE        BootMode;\r
+  UINT8                PcdFspApiVersion;\r
 \r
   DEBUG ((DEBUG_INFO, "FspPeiEntryPoint\n"));\r
+  PcdFspApiVersion = 1;\r
 \r
-  Status = PeiServicesLocatePpi (\r
-             &gFspInitDonePpiGuid,\r
-             0,\r
-             NULL,\r
-             (VOID **) &FspInitDone\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // 1st entry\r
-    //\r
-    DEBUG ((DEBUG_INFO, "1st entry\n"));\r
-    FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));\r
-    DEBUG ((DEBUG_INFO, "FspHeader - 0x%x\n", FspHeader));\r
-    if (FspHeader == NULL) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
+  FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));\r
+  DEBUG ((DEBUG_INFO, "FspHeader - 0x%x\n", FspHeader));\r
+  if (FspHeader == NULL) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
 \r
-    SecFspInit (FspHeader);\r
+  if ((PcdGet8 (PcdFspApiVersion) >= 2) &&\r
+      (FspHeader->HeaderRevision >= FSP_HEADER_REVISION_2) &&\r
+      (FspHeader->ApiEntryNum >= 6) &&\r
+      (FspHeader->FspMemoryInitEntryOffset != 0) &&\r
+      (FspHeader->TempRamExitEntryOffset != 0) &&\r
+      (FspHeader->FspSiliconInitEntryOffset != 0) ) {\r
+    PcdFspApiVersion = FSP_HEADER_REVISION_2;\r
+  }\r
+  DEBUG ((DEBUG_INFO, "PcdFspApiVersion - 0x%x\n", PcdFspApiVersion));\r
 \r
-    //\r
-    // Never return here\r
-    //\r
-    CpuDeadLoop ();\r
+  if (PcdFspApiVersion == FSP_HEADER_REVISION_1) {\r
+    PeiFspInitV1 (FspHeader);\r
   } else {\r
-    //\r
-    // 2nd entry\r
-    //\r
-    DEBUG ((DEBUG_INFO, "2nd entry\n"));\r
-    Status = FspInitDone->GetFspHobList (PeiServices, FspInitDone, &FspHobList);\r
-    DEBUG ((DEBUG_INFO, "FspHobList - 0x%x\n", FspHobList));\r
-    FspHobProcess (FspHobList);\r
-\r
-    PeiServicesGetBootMode (&BootMode);\r
-    if (BootMode == BOOT_ON_S3_RESUME) {\r
-      Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
+    PeiFspInitV2 (FspHeader);\r
   }\r
 \r
   return EFI_SUCCESS;\r