]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspPkg/FspSecCore/SecFsp.c
Clean update API name for ASM function.
[mirror_edk2.git] / IntelFspPkg / FspSecCore / SecFsp.c
index 00eb224c6f0e553650f7d0ecb48fa0c5b07f643a..a9aba7108e338c971208d360d0499c1561c830a9 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\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
@@ -13,8 +13,6 @@
 \r
 #include "SecFsp.h"\r
 \r
-UINT32  FspImageSizeOffset = FSP_INFO_HEADER_OFF + OFFSET_IN_FSP_INFO_HEADER(ImageSize);\r
-\r
 /**\r
 \r
   Calculate the FSP IDT gate descriptor.\r
@@ -34,7 +32,7 @@ FspGetExceptionHandler(
   IA32_IDT_GATE_DESCRIPTOR *IdtGateDescriptor;\r
   FSP_INFO_HEADER          *FspInfoHeader;\r
 \r
-  FspInfoHeader     = (FSP_INFO_HEADER *)(GetFspBaseAddress() + FSP_INFO_HEADER_OFF);\r
+  FspInfoHeader     = (FSP_INFO_HEADER *)AsmGetFspInfoHeader();\r
   ExceptionHandler  = IdtEntryTemplate;\r
   IdtGateDescriptor = (IA32_IDT_GATE_DESCRIPTOR *)&ExceptionHandler;\r
   Entry = (IdtGateDescriptor->Bits.OffsetHigh << 16) | IdtGateDescriptor->Bits.OffsetLow;\r
@@ -99,10 +97,10 @@ SecGetPlatformData (
   TopOfCar = PcdGet32 (PcdTemporaryRamBase) + PcdGet32 (PcdTemporaryRamSize);\r
 \r
   FspPlatformData->DataPtr   = NULL;\r
-  FspPlatformData->CodeRegionSize      = 0;\r
+  FspPlatformData->MicrocodeRegionBase = 0;\r
+  FspPlatformData->MicrocodeRegionSize = 0;\r
   FspPlatformData->CodeRegionBase      = 0;\r
-  FspPlatformData->MicorcodeRegionBase = 0;\r
-  FspPlatformData->MicorcodeRegionSize = 0;\r
+  FspPlatformData->CodeRegionSize      = 0;\r
 \r
   //\r
   // Pointer to the size field\r
@@ -116,7 +114,7 @@ SecGetPlatformData (
       //\r
       DwordSize = 4;\r
       StackPtr  = StackPtr - 1 - DwordSize;\r
-      CopyMem (&(FspPlatformData->CodeRegionBase), StackPtr, (DwordSize << 2));\r
+      CopyMem (&(FspPlatformData->MicrocodeRegionBase), StackPtr, (DwordSize << 2));\r
       StackPtr--;\r
     } else if (*(StackPtr - 1) == FSP_PER0_SIGNATURE) {\r
       //\r
@@ -140,13 +138,15 @@ SecGetPlatformData (
   It needs to be done as soon as possible after the stack is setup.\r
 \r
   @param[in,out] PeiFspData             Pointer of the FSP global data.\r
-  @param[in]     BootFirmwareVolume     Point to the address of BootFirmwareVolume in stack.\r
+  @param[in]     BootLoaderStack        BootLoader stack.\r
+  @param[in]     ApiIdx                 The index of the FSP API.\r
 \r
 **/\r
 VOID\r
 FspGlobalDataInit (\r
   IN OUT  FSP_GLOBAL_DATA    *PeiFspData,\r
-  IN      VOID              **BootFirmwareVolume\r
+  IN UINT32                   BootLoaderStack,\r
+  IN UINT8                    ApiIdx\r
   )\r
 {\r
   VOID              *UpdDataRgnPtr;\r
@@ -162,7 +162,7 @@ FspGlobalDataInit (
   ZeroMem  ((VOID *)PeiFspData, sizeof(FSP_GLOBAL_DATA));\r
 \r
   PeiFspData->Signature          = FSP_GLOBAL_DATA_SIGNATURE;\r
-  PeiFspData->CoreStack          = *(UINTN *)(BootFirmwareVolume + 2);\r
+  PeiFspData->CoreStack          = BootLoaderStack;\r
   PeiFspData->PerfIdx            = 2;\r
 \r
   SetFspMeasurePoint (FSP_PERF_ID_API_FSPINIT_ENTRY);\r
@@ -171,9 +171,14 @@ FspGlobalDataInit (
   // Get FSP Header offset\r
   // It may have multiple FVs, so look into the last one for FSP header\r
   //\r
-  PeiFspData->FspInfoHeader      = (FSP_INFO_HEADER *)(GetFspBaseAddress() + FSP_INFO_HEADER_OFF);\r
+  PeiFspData->FspInfoHeader      = (FSP_INFO_HEADER *)AsmGetFspInfoHeader();\r
   SecGetPlatformData (PeiFspData);\r
 \r
+  //\r
+  // Set API calling mode\r
+  //\r
+  SetFspApiCallingMode (ApiIdx == 1 ? 0 : 1);\r
+\r
   //\r
   // Initialize UPD pointer.\r
   //\r
@@ -202,8 +207,13 @@ FspGlobalDataInit (
   }\r
   ImageId[Idx] = 0;\r
 \r
-  DEBUG ((DEBUG_INFO | DEBUG_INIT, "\n============= PEIM FSP  (%a 0x%08X) =============\n", \\r
-         ImageId, PeiFspData->FspInfoHeader->ImageRevision));\r
+  DEBUG ((DEBUG_INFO | DEBUG_INIT, "\n============= PEIM FSP v1.%x (%a v%x.%x.%x.%x) =============\n", \\r
+         PeiFspData->FspInfoHeader->HeaderRevision - 1, \\r
+         ImageId, \\r
+         (PeiFspData->FspInfoHeader->ImageRevision >> 24) & 0xff, \\r
+         (PeiFspData->FspInfoHeader->ImageRevision >> 16) & 0xff, \\r
+         (PeiFspData->FspInfoHeader->ImageRevision >> 8) & 0xff, \\r
+         (PeiFspData->FspInfoHeader->ImageRevision >> 0) & 0xff));\r
 \r
 }\r
 \r
@@ -229,25 +239,34 @@ FspDataPointerFixUp (
   This function check the FSP API calling condition.\r
 \r
   @param[in]  ApiIdx           Internal index of the FSP API.\r
+  @param[in]  ApiParam         Parameter of the FSP API.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 FspApiCallingCheck (\r
-  UINT32   ApiIdx\r
+  IN UINT32   ApiIdx,\r
+  IN VOID     *ApiParam\r
   )\r
 {\r
-  EFI_STATUS       Status;\r
-  FSP_GLOBAL_DATA *FspData;\r
+  EFI_STATUS                Status;\r
+  FSP_GLOBAL_DATA           *FspData;\r
+  FSP_INIT_PARAMS           *FspInitParams;\r
+  FSP_INIT_RT_COMMON_BUFFER *FspRtBuffer;\r
+\r
+  FspInitParams = (FSP_INIT_PARAMS *) ApiParam;\r
+  FspRtBuffer = ((FSP_INIT_RT_COMMON_BUFFER *)FspInitParams->RtBufferPtr);\r
 \r
   Status = EFI_SUCCESS;\r
-  FspData  = GetFspGlobalDataPointer ();\r
+  FspData = GetFspGlobalDataPointer ();\r
   if (ApiIdx == 1) {\r
     //\r
     // FspInit check\r
     //\r
     if ((UINT32)FspData != 0xFFFFFFFF) {\r
       Status = EFI_UNSUPPORTED;\r
+    } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0)) {\r
+      Status = EFI_INVALID_PARAMETER;\r
     }\r
   } else if (ApiIdx == 2) {\r
     //\r
@@ -260,9 +279,54 @@ FspApiCallingCheck (
         Status = EFI_UNSUPPORTED;\r
       }\r
     }\r
+  } else if (ApiIdx == 3) {\r
+    //\r
+    // FspMemoryInit check\r
+    //\r
+    if ((UINT32)FspData != 0xFFFFFFFF) {\r
+      Status = EFI_UNSUPPORTED;\r
+    } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0)) {\r
+      Status = EFI_INVALID_PARAMETER;\r
+    }\r
+  } else if (ApiIdx == 4) {\r
+    //\r
+    // TempRamExit check\r
+    //\r
+    if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r
+      Status = EFI_UNSUPPORTED;\r
+    } else {\r
+      if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r
+        Status = EFI_UNSUPPORTED;\r
+      }\r
+    }\r
+  } else if (ApiIdx == 5) {\r
+    //\r
+    // FspSiliconInit check\r
+    //\r
+    if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r
+      Status = EFI_UNSUPPORTED;\r
+    } else {\r
+      if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r
+        Status = EFI_UNSUPPORTED;\r
+      }\r
+    }\r
   } else {\r
     Status = EFI_UNSUPPORTED;\r
   }\r
 \r
   return Status;\r
 }\r
+\r
+/**\r
+  This function gets the boot FV offset in FSP.\r
+  @return the boot firmware volumen offset inside FSP binary\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GetBootFirmwareVolumeOffset (\r
+  VOID\r
+  )\r
+{ \r
+  return PcdGet32 (PcdFspBootFirmwareVolumeBase) - PcdGet32 (PcdFspAreaBaseAddress);\r
+}\r