Revision: 18123
          http://sourceforge.net/p/edk2/code/18123
Author:   jyao1
Date:     2015-08-02 04:02:37 +0000 (Sun, 02 Aug 2015)
Log Message:
-----------
Add Dual-FSP support (MemoryInitUpd/SiliconInitUpd)

Add FspUpdSignatureCheck() API in FspSecPlatformLib, so that FspSecCore can 
check if UPD data is valid in FSP API.
Add Set/GetFspMemoryInitUpdDataPointer() and 
Set/GetFspSiliconInitUpdDataPointer() API in FspCommonLib,
 so that core can set this UdpDataPointer and platform code may get 
UpdDataPointer easily.
Add UpdateMemSiUpdInitOffsetValue function in GenCfgOpt.py tool, so that the 
MemoryInitUpdOffset and SiUpdInitOffset is recorded.
Add missing EMBED comment in GenCfgOptUserManual.docx

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <[email protected]>
Reviewed-by: "Mudusuru, Giri P" <[email protected]>

Modified Paths:
--------------
    trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.c
    trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.h
    trunk/edk2/IntelFspPkg/Include/Library/FspCommonLib.h
    trunk/edk2/IntelFspPkg/Include/Library/FspSecPlatformLib.h
    trunk/edk2/IntelFspPkg/Include/Private/FspGlobalData.h
    trunk/edk2/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c
    trunk/edk2/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c
    trunk/edk2/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c
    trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py
    trunk/edk2/IntelFspPkg/Tools/UserManuals/GenCfgOptUserManual.docx

Modified: trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.c
===================================================================
--- trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.c  2015-07-31 08:24:18 UTC (rev 
18122)
+++ trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.c  2015-08-02 04:02:37 UTC (rev 
18123)
@@ -265,7 +265,7 @@
     //
     if ((UINT32)FspData != 0xFFFFFFFF) {
       Status = EFI_UNSUPPORTED;
-    } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % 
EFI_PAGE_SIZE) != 0)) {
+    } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % 
EFI_PAGE_SIZE) != 0) || (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam)))) {
       Status = EFI_INVALID_PARAMETER;
     }
   } else if (ApiIdx == 2) {
@@ -285,7 +285,7 @@
     //
     if ((UINT32)FspData != 0xFFFFFFFF) {
       Status = EFI_UNSUPPORTED;
-    } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % 
EFI_PAGE_SIZE) != 0)) {
+    } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % 
EFI_PAGE_SIZE) != 0) || (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam)))) {
       Status = EFI_INVALID_PARAMETER;
     }
   } else if (ApiIdx == 4) {
@@ -308,6 +308,8 @@
     } else {
       if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
         Status = EFI_UNSUPPORTED;
+      } else if (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam))) {
+        Status = EFI_INVALID_PARAMETER;
       }
     }
   } else {

Modified: trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.h
===================================================================
--- trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.h  2015-07-31 08:24:18 UTC (rev 
18122)
+++ trunk/edk2/IntelFspPkg/FspSecCore/SecFsp.h  2015-08-02 04:02:37 UTC (rev 
18123)
@@ -15,15 +15,15 @@
 #define _SEC_FSPE_H_
 
 #include <PiPei.h>
+#include <FspApi.h>
 #include <Library/PcdLib.h>
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
 #include <Library/SerialPortLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/FspCommonLib.h>
+#include <Library/FspSecPlatformLib.h>
 
-#include <FspApi.h>
-
 #define FSP_MCUD_SIGNATURE  SIGNATURE_32 ('M', 'C', 'U', 'D')
 #define FSP_PER0_SIGNATURE  SIGNATURE_32 ('P', 'E', 'R', '0')
 

Modified: trunk/edk2/IntelFspPkg/Include/Library/FspCommonLib.h
===================================================================
--- trunk/edk2/IntelFspPkg/Include/Library/FspCommonLib.h       2015-07-31 
08:24:18 UTC (rev 18122)
+++ trunk/edk2/IntelFspPkg/Include/Library/FspCommonLib.h       2015-08-02 
04:02:37 UTC (rev 18123)
@@ -158,6 +158,50 @@
   );
 
 /**
+  This function sets the memory init UPD data pointer.
+
+  @param[in] MemoryInitUpdPtr   memory init UPD data pointer.
+**/
+VOID
+EFIAPI
+SetFspMemoryInitUpdDataPointer (
+  IN VOID    *MemoryInitUpdPtr
+  );
+
+/**
+  This function gets the memory init UPD data pointer.
+
+  @return memory init UPD data pointer.
+**/
+VOID *
+EFIAPI
+GetFspMemoryInitUpdDataPointer (
+  VOID
+  );
+
+/**
+  This function sets the silicon init UPD data pointer.
+
+  @param[in] SiliconInitUpdPtr   silicon init UPD data pointer.
+**/
+VOID
+EFIAPI
+SetFspSiliconInitUpdDataPointer (
+  IN VOID    *SiliconInitUpdPtr
+  );
+
+/**
+  This function gets the silicon init UPD data pointer.
+
+  @return silicon init UPD data pointer.
+**/
+VOID *
+EFIAPI
+GetFspSiliconInitUpdDataPointer (
+  VOID
+  );
+
+/**
   Set FSP measurement point timestamp.
 
   @param[in] Id       Measurement point ID.

Modified: trunk/edk2/IntelFspPkg/Include/Library/FspSecPlatformLib.h
===================================================================
--- trunk/edk2/IntelFspPkg/Include/Library/FspSecPlatformLib.h  2015-07-31 
08:24:18 UTC (rev 18122)
+++ trunk/edk2/IntelFspPkg/Include/Library/FspSecPlatformLib.h  2015-08-02 
04:02:37 UTC (rev 18123)
@@ -71,4 +71,18 @@
   IN FSP_TEMP_RAM_INIT_PARAMS  *TempRamInitParamPtr
   );
 
+/**
+  This function check the signture of UPD.
+
+  @param[in]  ApiIdx           Internal index of the FSP API.
+  @param[in]  ApiParam         Parameter of the FSP API.
+
+**/
+EFI_STATUS
+EFIAPI
+FspUpdSignatureCheck (
+  IN UINT32   ApiIdx,
+  IN VOID     *ApiParam
+  );
+
 #endif

Modified: trunk/edk2/IntelFspPkg/Include/Private/FspGlobalData.h
===================================================================
--- trunk/edk2/IntelFspPkg/Include/Private/FspGlobalData.h      2015-07-31 
08:24:18 UTC (rev 18122)
+++ trunk/edk2/IntelFspPkg/Include/Private/FspGlobalData.h      2015-08-02 
04:02:37 UTC (rev 18123)
@@ -34,6 +34,8 @@
    FSP_PLAT_DATA      PlatformData;
    FSP_INFO_HEADER    *FspInfoHeader;
    VOID               *UpdDataRgnPtr;
+   VOID               *MemoryInitUpdPtr;
+   VOID               *SiliconInitUpdPtr;
    UINT8              ApiMode;
    UINT8              Reserved[3];
    UINT32             PerfIdx;

Modified: trunk/edk2/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c
===================================================================
--- trunk/edk2/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c      
2015-07-31 08:24:18 UTC (rev 18122)
+++ trunk/edk2/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c      
2015-08-02 04:02:37 UTC (rev 18123)
@@ -289,7 +289,92 @@
   return FspData->UpdDataRgnPtr;
 }
 
+
 /**
+  This function sets the memory init UPD data pointer.
+
+  @param[in] MemoryInitUpdPtr   memory init UPD data pointer.
+**/
+VOID
+EFIAPI
+SetFspMemoryInitUpdDataPointer (
+  IN VOID    *MemoryInitUpdPtr
+  )
+{
+  FSP_GLOBAL_DATA  *FspData;
+
+  //
+  // Get the Fsp Global Data Pointer
+  //
+  FspData  = GetFspGlobalDataPointer ();
+
+  //
+  // Set the memory init UPD pointer.
+  //
+  FspData->MemoryInitUpdPtr = MemoryInitUpdPtr;
+}
+
+/**
+  This function gets the memory init UPD data pointer.
+
+  @return memory init UPD data pointer.
+**/
+VOID *
+EFIAPI
+GetFspMemoryInitUpdDataPointer (
+  VOID
+  )
+{
+  FSP_GLOBAL_DATA  *FspData;
+
+  FspData  = GetFspGlobalDataPointer ();
+  return FspData->MemoryInitUpdPtr;
+}
+
+
+/**
+  This function sets the silicon init UPD data pointer.
+
+  @param[in] SiliconInitUpdPtr   silicon init UPD data pointer.
+**/
+VOID
+EFIAPI
+SetFspSiliconInitUpdDataPointer (
+  IN VOID    *SiliconInitUpdPtr
+  )
+{
+  FSP_GLOBAL_DATA  *FspData;
+
+  //
+  // Get the Fsp Global Data Pointer
+  //
+  FspData  = GetFspGlobalDataPointer ();
+
+  //
+  // Set the silicon init UPD data pointer.
+  //
+  FspData->SiliconInitUpdPtr = SiliconInitUpdPtr;
+}
+
+/**
+  This function gets the silicon init UPD data pointer.
+
+  @return silicon init UPD data pointer.
+**/
+VOID *
+EFIAPI
+GetFspSiliconInitUpdDataPointer (
+  VOID
+  )
+{
+  FSP_GLOBAL_DATA  *FspData;
+
+  FspData  = GetFspGlobalDataPointer ();
+  return FspData->SiliconInitUpdPtr;
+}
+
+
+/**
   Set FSP measurement point timestamp.
 
   @param[in] Id       Measurement point ID.

Modified: trunk/edk2/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c
===================================================================
--- trunk/edk2/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c       
2015-07-31 08:24:18 UTC (rev 18122)
+++ trunk/edk2/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c       
2015-08-02 04:02:37 UTC (rev 18123)
@@ -86,7 +86,9 @@
   FSP_INIT_PARAMS           *FspInitParams;
   UINT32                    *NewStackTop;
   VOID                      *BootLoaderTempRamHob;
-  VOID                      *UpdDataRgnPtr;
+  UINT32                    UpdDataRgnPtr;
+  UINT32                    MemoryInitUpdPtr;
+  UINT32                    SiliconInitUpdPtr;
   VOID                      *PlatformDataPtr;
   UINT8                      ApiMode;
     
@@ -105,7 +107,7 @@
   if (ApiMode == 0) {
     BootLoaderTempRamHob = BuildGuidHob (&gFspBootLoaderTemporaryMemoryGuid, 
BootLoaderTempRamSize);
   } else {
-    BootLoaderTempRamHob = (VOID *)AllocatePool (BootLoaderTempRamSize);
+    BootLoaderTempRamHob = (VOID *)AllocatePages (EFI_SIZE_TO_PAGES 
(BootLoaderTempRamSize));
   }
   ASSERT(BootLoaderTempRamHob != NULL);
 
@@ -150,9 +152,20 @@
   //
   // Update UPD pointer in FSP Global Data
   //
-  UpdDataRgnPtr = ((FSP_INIT_RT_COMMON_BUFFER 
*)FspInitParams->RtBufferPtr)->UpdDataRgnPtr;
-  if (UpdDataRgnPtr != NULL) {
-    SetFspUpdDataPointer (UpdDataRgnPtr);
+  if (ApiMode == 0) {
+    UpdDataRgnPtr = (UINT32)((UINT32 *)GetFspUpdDataPointer ());
+    if (UpdDataRgnPtr >= BootLoaderTempRamStart && UpdDataRgnPtr < 
BootLoaderTempRamEnd) {
+      MemoryInitUpdPtr = (UINT32)((UINT32 *)GetFspMemoryInitUpdDataPointer ());
+      SiliconInitUpdPtr = (UINT32)((UINT32 *)GetFspSiliconInitUpdDataPointer 
());
+      SetFspUpdDataPointer ((VOID *)(UpdDataRgnPtr + OffsetGap));
+      SetFspMemoryInitUpdDataPointer ((VOID *)(MemoryInitUpdPtr + OffsetGap));
+      SetFspSiliconInitUpdDataPointer ((VOID *)(SiliconInitUpdPtr + 
OffsetGap));
+    }
+  } else {
+    MemoryInitUpdPtr = (UINT32)((UINT32 *)GetFspMemoryInitUpdDataPointer ());
+    if (MemoryInitUpdPtr >= BootLoaderTempRamStart && MemoryInitUpdPtr < 
BootLoaderTempRamEnd) {
+      SetFspMemoryInitUpdDataPointer ((VOID *)(MemoryInitUpdPtr + OffsetGap));
+    }
   }
 
   //

Modified: 
trunk/edk2/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c
===================================================================
--- 
trunk/edk2/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c    
    2015-07-31 08:24:18 UTC (rev 18122)
+++ 
trunk/edk2/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c    
    2015-08-02 04:02:37 UTC (rev 18123)
@@ -14,4 +14,21 @@
 
 #include <PiPei.h>
 
+/**
+  This function check the signture of UPD.
 
+  @param[in]  ApiIdx           Internal index of the FSP API.
+  @param[in]  ApiParam         Parameter of the FSP API.
+
+**/
+EFI_STATUS
+EFIAPI
+FspUpdSignatureCheck (
+  IN UINT32   ApiIdx,
+  IN VOID     *ApiParam
+  )
+{
+  return EFI_SUCCESS;
+}
+
+

Modified: trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py
===================================================================
--- trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py   2015-07-31 08:24:18 UTC (rev 
18122)
+++ trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py   2015-08-02 04:02:37 UTC (rev 
18123)
@@ -88,6 +88,48 @@
 **/
 """
 
+def UpdateMemSiUpdInitOffsetValue (DscFile):
+    DscFd        = open(DscFile, "r")
+    DscLines     = DscFd.readlines()
+    DscFd.close()
+
+    DscContent = []
+    MemUpdInitOffset = 0
+    SiUpdInitOffset = 0
+    MemUpdInitOffsetValue = 0
+    SiUpdInitOffsetValue = 0
+
+    while len(DscLines):
+        DscLine  = DscLines.pop(0)
+        DscContent.append(DscLine)
+        DscLine = DscLine.strip()
+        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)
+        if Match:
+            MemUpdInitOffsetValue = int(Match.group(5), 0)
+        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)
+        if Match:
+            SiUpdInitOffsetValue = int(Match.group(5), 0)
+        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)
+        if Match:
+            MemUpdInitOffset = int(Match.group(3), 0)
+        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)
+        if Match:
+            SiUpdInitOffset = int(Match.group(3), 0)
+
+    if MemUpdInitOffsetValue != MemUpdInitOffset or SiUpdInitOffsetValue != 
SiUpdInitOffset:
+        MemUpdInitOffsetStr = "0x%08X" % MemUpdInitOffset
+        SiUpdInitOffsetStr = "0x%08X" % SiUpdInitOffset
+        DscFd = open(DscFile,"w")
+        for DscLine in DscContent:
+            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)
+            if Match:
+                 DscLine = re.sub(r'(?:[^\s]+\s*$)', MemUpdInitOffsetStr + 
'\n', DscLine)
+            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)
+            if Match:
+                 DscLine = re.sub(r'(?:[^\s]+\s*$)', SiUpdInitOffsetStr + 
'\n', line)
+            DscFd.writelines(DscLine)
+        DscFd.close()
+
 class CLogicalExpression:
     def __init__(self):
         self.index    = 0
@@ -889,6 +931,22 @@
                 return 256
 
         TxtBody = []
+        for Item in self._CfgItemList:
+           if str(Item['cname']) == 'Signature' and Item['length'] == 8:
+               Value = int(Item['value'], 16)
+               Chars = []
+               while Value != 0x0:
+                   Chars.append(chr(Value & 0xFF))
+                   Value = Value >> 8
+               SignatureStr = ''.join(Chars)
+               if int(Item['offset']) == 0:
+                   TxtBody.append("#define FSP_UPD_SIGNATURE                %s 
       /* '%s' */\n" % (Item['value'], SignatureStr))
+               elif 'MEM' in SignatureStr:
+                   TxtBody.append("#define FSP_MEMORY_INIT_UPD_SIGNATURE    %s 
       /* '%s' */\n" % (Item['value'], SignatureStr))
+               else:
+                   TxtBody.append("#define FSP_SILICON_INIT_UPD_SIGNATURE   %s 
       /* '%s' */\n" % (Item['value'], SignatureStr))
+        TxtBody.append("\n")
+
         for Region in ['UPD', 'VPD']:
 
             # Write  PcdVpdRegionSign and PcdImageRevision
@@ -1176,6 +1234,8 @@
             print "ERROR: Cannot open DSC file '%s' !" % DscFile
             return 2
 
+        UpdateMemSiUpdInitOffsetValue(DscFile)
+
         OutFile = ''
         if argc > 4:
             if sys.argv[4][0] == '-':

Modified: trunk/edk2/IntelFspPkg/Tools/UserManuals/GenCfgOptUserManual.docx
===================================================================
(Binary files differ)


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to