//\r
if ((UINT32)FspData != 0xFFFFFFFF) {\r
Status = EFI_UNSUPPORTED;\r
- } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0)) {\r
+ } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0) || (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam)))) {\r
Status = EFI_INVALID_PARAMETER;\r
}\r
} else if (ApiIdx == 2) {\r
//\r
if ((UINT32)FspData != 0xFFFFFFFF) {\r
Status = EFI_UNSUPPORTED;\r
- } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0)) {\r
+ } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0) || (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam)))) {\r
Status = EFI_INVALID_PARAMETER;\r
}\r
} else if (ApiIdx == 4) {\r
} else {\r
if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r
Status = EFI_UNSUPPORTED;\r
+ } else if (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam))) {\r
+ Status = EFI_INVALID_PARAMETER;\r
}\r
}\r
} else {\r
#define _SEC_FSPE_H_\r
\r
#include <PiPei.h>\r
+#include <FspApi.h>\r
#include <Library/PcdLib.h>\r
#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/SerialPortLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/FspCommonLib.h>\r
-\r
-#include <FspApi.h>\r
+#include <Library/FspSecPlatformLib.h>\r
\r
#define FSP_MCUD_SIGNATURE SIGNATURE_32 ('M', 'C', 'U', 'D')\r
#define FSP_PER0_SIGNATURE SIGNATURE_32 ('P', 'E', 'R', '0')\r
VOID\r
);\r
\r
+/**\r
+ This function sets the memory init UPD data pointer.\r
+\r
+ @param[in] MemoryInitUpdPtr memory init UPD data pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetFspMemoryInitUpdDataPointer (\r
+ IN VOID *MemoryInitUpdPtr\r
+ );\r
+\r
+/**\r
+ This function gets the memory init UPD data pointer.\r
+\r
+ @return memory init UPD data pointer.\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetFspMemoryInitUpdDataPointer (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function sets the silicon init UPD data pointer.\r
+\r
+ @param[in] SiliconInitUpdPtr silicon init UPD data pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetFspSiliconInitUpdDataPointer (\r
+ IN VOID *SiliconInitUpdPtr\r
+ );\r
+\r
+/**\r
+ This function gets the silicon init UPD data pointer.\r
+\r
+ @return silicon init UPD data pointer.\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetFspSiliconInitUpdDataPointer (\r
+ VOID\r
+ );\r
+\r
/**\r
Set FSP measurement point timestamp.\r
\r
IN FSP_TEMP_RAM_INIT_PARAMS *TempRamInitParamPtr\r
);\r
\r
+/**\r
+ This function check the signture of UPD.\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
+FspUpdSignatureCheck (\r
+ IN UINT32 ApiIdx,\r
+ IN VOID *ApiParam\r
+ );\r
+\r
#endif\r
FSP_PLAT_DATA PlatformData;\r
FSP_INFO_HEADER *FspInfoHeader;\r
VOID *UpdDataRgnPtr;\r
+ VOID *MemoryInitUpdPtr;\r
+ VOID *SiliconInitUpdPtr;\r
UINT8 ApiMode;\r
UINT8 Reserved[3];\r
UINT32 PerfIdx;\r
return FspData->UpdDataRgnPtr;\r
}\r
\r
+\r
+/**\r
+ This function sets the memory init UPD data pointer.\r
+\r
+ @param[in] MemoryInitUpdPtr memory init UPD data pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetFspMemoryInitUpdDataPointer (\r
+ IN VOID *MemoryInitUpdPtr\r
+ )\r
+{\r
+ FSP_GLOBAL_DATA *FspData;\r
+\r
+ //\r
+ // Get the Fsp Global Data Pointer\r
+ //\r
+ FspData = GetFspGlobalDataPointer ();\r
+\r
+ //\r
+ // Set the memory init UPD pointer.\r
+ //\r
+ FspData->MemoryInitUpdPtr = MemoryInitUpdPtr;\r
+}\r
+\r
+/**\r
+ This function gets the memory init UPD data pointer.\r
+\r
+ @return memory init UPD data pointer.\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetFspMemoryInitUpdDataPointer (\r
+ VOID\r
+ )\r
+{\r
+ FSP_GLOBAL_DATA *FspData;\r
+\r
+ FspData = GetFspGlobalDataPointer ();\r
+ return FspData->MemoryInitUpdPtr;\r
+}\r
+\r
+\r
+/**\r
+ This function sets the silicon init UPD data pointer.\r
+\r
+ @param[in] SiliconInitUpdPtr silicon init UPD data pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetFspSiliconInitUpdDataPointer (\r
+ IN VOID *SiliconInitUpdPtr\r
+ )\r
+{\r
+ FSP_GLOBAL_DATA *FspData;\r
+\r
+ //\r
+ // Get the Fsp Global Data Pointer\r
+ //\r
+ FspData = GetFspGlobalDataPointer ();\r
+\r
+ //\r
+ // Set the silicon init UPD data pointer.\r
+ //\r
+ FspData->SiliconInitUpdPtr = SiliconInitUpdPtr;\r
+}\r
+\r
+/**\r
+ This function gets the silicon init UPD data pointer.\r
+\r
+ @return silicon init UPD data pointer.\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetFspSiliconInitUpdDataPointer (\r
+ VOID\r
+ )\r
+{\r
+ FSP_GLOBAL_DATA *FspData;\r
+\r
+ FspData = GetFspGlobalDataPointer ();\r
+ return FspData->SiliconInitUpdPtr;\r
+}\r
+\r
+\r
/**\r
Set FSP measurement point timestamp.\r
\r
FSP_INIT_PARAMS *FspInitParams;\r
UINT32 *NewStackTop;\r
VOID *BootLoaderTempRamHob;\r
- VOID *UpdDataRgnPtr;\r
+ UINT32 UpdDataRgnPtr;\r
+ UINT32 MemoryInitUpdPtr;\r
+ UINT32 SiliconInitUpdPtr;\r
VOID *PlatformDataPtr;\r
UINT8 ApiMode;\r
\r
if (ApiMode == 0) {\r
BootLoaderTempRamHob = BuildGuidHob (&gFspBootLoaderTemporaryMemoryGuid, BootLoaderTempRamSize);\r
} else {\r
- BootLoaderTempRamHob = (VOID *)AllocatePool (BootLoaderTempRamSize);\r
+ BootLoaderTempRamHob = (VOID *)AllocatePages (EFI_SIZE_TO_PAGES (BootLoaderTempRamSize));\r
}\r
ASSERT(BootLoaderTempRamHob != NULL);\r
\r
//\r
// Update UPD pointer in FSP Global Data\r
//\r
- UpdDataRgnPtr = ((FSP_INIT_RT_COMMON_BUFFER *)FspInitParams->RtBufferPtr)->UpdDataRgnPtr;\r
- if (UpdDataRgnPtr != NULL) {\r
- SetFspUpdDataPointer (UpdDataRgnPtr);\r
+ if (ApiMode == 0) {\r
+ UpdDataRgnPtr = (UINT32)((UINT32 *)GetFspUpdDataPointer ());\r
+ if (UpdDataRgnPtr >= BootLoaderTempRamStart && UpdDataRgnPtr < BootLoaderTempRamEnd) {\r
+ MemoryInitUpdPtr = (UINT32)((UINT32 *)GetFspMemoryInitUpdDataPointer ());\r
+ SiliconInitUpdPtr = (UINT32)((UINT32 *)GetFspSiliconInitUpdDataPointer ());\r
+ SetFspUpdDataPointer ((VOID *)(UpdDataRgnPtr + OffsetGap));\r
+ SetFspMemoryInitUpdDataPointer ((VOID *)(MemoryInitUpdPtr + OffsetGap));\r
+ SetFspSiliconInitUpdDataPointer ((VOID *)(SiliconInitUpdPtr + OffsetGap));\r
+ }\r
+ } else {\r
+ MemoryInitUpdPtr = (UINT32)((UINT32 *)GetFspMemoryInitUpdDataPointer ());\r
+ if (MemoryInitUpdPtr >= BootLoaderTempRamStart && MemoryInitUpdPtr < BootLoaderTempRamEnd) {\r
+ SetFspMemoryInitUpdDataPointer ((VOID *)(MemoryInitUpdPtr + OffsetGap));\r
+ }\r
}\r
\r
//\r
\r
#include <PiPei.h>\r
\r
+/**\r
+ This function check the signture of UPD.\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
+FspUpdSignatureCheck (\r
+ IN UINT32 ApiIdx,\r
+ IN VOID *ApiParam\r
+ )\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
\r
**/\r
"""\r
\r
+def UpdateMemSiUpdInitOffsetValue (DscFile):\r
+ DscFd = open(DscFile, "r")\r
+ DscLines = DscFd.readlines()\r
+ DscFd.close()\r
+\r
+ DscContent = []\r
+ MemUpdInitOffset = 0\r
+ SiUpdInitOffset = 0\r
+ MemUpdInitOffsetValue = 0\r
+ SiUpdInitOffsetValue = 0\r
+\r
+ while len(DscLines):\r
+ DscLine = DscLines.pop(0)\r
+ DscContent.append(DscLine)\r
+ DscLine = DscLine.strip()\r
+ Match = re.match("^([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+ if Match:\r
+ MemUpdInitOffsetValue = int(Match.group(5), 0)\r
+ Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+ if Match:\r
+ SiUpdInitOffsetValue = int(Match.group(5), 0)\r
+ Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450554D454D24)",DscLine)\r
+ if Match:\r
+ MemUpdInitOffset = int(Match.group(3), 0)\r
+ Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450555F495324)",DscLine)\r
+ if Match:\r
+ SiUpdInitOffset = int(Match.group(3), 0)\r
+\r
+ if MemUpdInitOffsetValue != MemUpdInitOffset or SiUpdInitOffsetValue != SiUpdInitOffset:\r
+ MemUpdInitOffsetStr = "0x%08X" % MemUpdInitOffset\r
+ SiUpdInitOffsetStr = "0x%08X" % SiUpdInitOffset\r
+ DscFd = open(DscFile,"w")\r
+ for DscLine in DscContent:\r
+ Match = re.match("^\s*([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+ if Match:\r
+ DscLine = re.sub(r'(?:[^\s]+\s*$)', MemUpdInitOffsetStr + '\n', DscLine)\r
+ Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+ if Match:\r
+ DscLine = re.sub(r'(?:[^\s]+\s*$)', SiUpdInitOffsetStr + '\n', line)\r
+ DscFd.writelines(DscLine)\r
+ DscFd.close()\r
+\r
class CLogicalExpression:\r
def __init__(self):\r
self.index = 0\r
return 256\r
\r
TxtBody = []\r
+ for Item in self._CfgItemList:\r
+ if str(Item['cname']) == 'Signature' and Item['length'] == 8:\r
+ Value = int(Item['value'], 16)\r
+ Chars = []\r
+ while Value != 0x0:\r
+ Chars.append(chr(Value & 0xFF))\r
+ Value = Value >> 8\r
+ SignatureStr = ''.join(Chars)\r
+ if int(Item['offset']) == 0:\r
+ TxtBody.append("#define FSP_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr))\r
+ elif 'MEM' in SignatureStr:\r
+ TxtBody.append("#define FSP_MEMORY_INIT_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr))\r
+ else:\r
+ TxtBody.append("#define FSP_SILICON_INIT_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr))\r
+ TxtBody.append("\n")\r
+\r
for Region in ['UPD', 'VPD']:\r
\r
# Write PcdVpdRegionSign and PcdImageRevision\r
print "ERROR: Cannot open DSC file '%s' !" % DscFile\r
return 2\r
\r
+ UpdateMemSiUpdInitOffsetValue(DscFile)\r
+\r
OutFile = ''\r
if argc > 4:\r
if sys.argv[4][0] == '-':\r