]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: Add FSP*_ARCH_UPD.
authorChasel Chiu <chasel.chiu@intel.com>
Thu, 4 Jun 2020 06:43:40 +0000 (14:43 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 23 Jun 2020 04:22:49 +0000 (04:22 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2781

Introduce FSPT_ARCH_UPD and FSPS_ARCH_UPD to support debug events
and multi-phase silicon initialization.
For backward compatibility the original structures are kept and
new ARCH_UPD structures will be included only when UPD header
revision equal or greater than 2.

GenCfgOpt script also updated to prevent from generating duplicate
FSPT_ARCH_UPD and FSPS_ARCH_UPD typedef structures.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
IntelFsp2Pkg/Include/FspEas/FspApi.h
IntelFsp2Pkg/Tools/GenCfgOpt.py

index e354870a1daa848f750d8312799d3b68fb5bc76b..7934eab6d7ae59dc2c43b405327391d475abc08c 100644 (file)
@@ -1,7 +1,7 @@
 ;; @file\r
 ;  Provide FSP API entry points.\r
 ;\r
-; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
 ; SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ;;\r
 \r
@@ -78,6 +78,23 @@ struc LoadMicrocodeParams
     .size:\r
 endstruc\r
 \r
+struc LoadMicrocodeParamsFsp22\r
+    ; FSP_UPD_HEADER {\r
+    .FspUpdHeaderSignature:   resd    2\r
+    .FspUpdHeaderRevision:    resb    1\r
+    .FspUpdHeaderReserved:    resb   23\r
+    ; }\r
+    ; FSPT_ARCH_UPD{\r
+    .FsptArchUpd:             resd    8\r
+    ; }\r
+    ; FSPT_CORE_UPD {\r
+    .MicrocodeCodeAddr:       resd    1\r
+    .MicrocodeCodeSize:       resd    1\r
+    .CodeRegionBase:          resd    1\r
+    .CodeRegionSize:          resd    1\r
+    ; }\r
+    .size:\r
+endstruc\r
 \r
 ;\r
 ; Define SSE macros\r
@@ -169,6 +186,11 @@ ASM_PFX(LoadMicrocodeDefault):
 \r
    ; skip loading Microcode if the MicrocodeCodeSize is zero\r
    ; and report error if size is less than 2k\r
+   ; first check UPD header revision\r
+   cmp    byte [esp + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2\r
+   jae    Fsp22UpdHeader\r
+\r
+   ; UPD structure is compliant with FSP spec 2.0/2.1\r
    mov    eax, dword [esp + LoadMicrocodeParams.MicrocodeCodeSize]\r
    cmp    eax, 0\r
    jz     Exit2\r
@@ -178,6 +200,19 @@ ASM_PFX(LoadMicrocodeDefault):
    mov    esi, dword [esp + LoadMicrocodeParams.MicrocodeCodeAddr]\r
    cmp    esi, 0\r
    jnz    CheckMainHeader\r
+   jmp    ParamError\r
+\r
+Fsp22UpdHeader:\r
+   ; UPD structure is compliant with FSP spec 2.2\r
+   mov    eax, dword [esp + LoadMicrocodeParamsFsp22.MicrocodeCodeSize]\r
+   cmp    eax, 0\r
+   jz     Exit2\r
+   cmp    eax, 0800h\r
+   jl     ParamError\r
+\r
+   mov    esi, dword [esp + LoadMicrocodeParamsFsp22.MicrocodeCodeAddr]\r
+   cmp    esi, 0\r
+   jnz    CheckMainHeader\r
 \r
 ParamError:\r
    mov    eax, 080000002h\r
@@ -276,6 +311,11 @@ CheckAddress:
    cmp   dword [esi + MicrocodeHdr.MicrocodeHdrVersion], 0ffffffffh\r
    jz    Done\r
 \r
+   ; Check UPD header revision\r
+   cmp    byte [esp + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2\r
+   jae    Fsp22UpdHeader1\r
+\r
+   ; UPD structure is compliant with FSP spec 2.0/2.1\r
    ; Is automatic size detection ?\r
    mov   eax, dword [esp + LoadMicrocodeParams.MicrocodeCodeSize]\r
    cmp   eax, 0ffffffffh\r
@@ -287,6 +327,19 @@ CheckAddress:
    jae   Done        ;Jif address is outside of microcode region\r
    jmp   CheckMainHeader\r
 \r
+Fsp22UpdHeader1:\r
+   ; UPD structure is compliant with FSP spec 2.2\r
+   ; Is automatic size detection ?\r
+   mov   eax, dword [esp + LoadMicrocodeParamsFsp22.MicrocodeCodeSize]\r
+   cmp   eax, 0ffffffffh\r
+   jz    LoadMicrocodeDefault4\r
+\r
+   ; Address >= microcode region address + microcode region size?\r
+   add   eax, dword [esp + LoadMicrocodeParamsFsp22.MicrocodeCodeAddr]\r
+   cmp   esi, eax\r
+   jae   Done        ;Jif address is outside of microcode region\r
+   jmp   CheckMainHeader\r
+\r
 LoadMicrocodeDefault4:\r
 LoadCheck:\r
    ; Get the revision of the current microcode update loaded\r
@@ -349,11 +402,26 @@ ASM_PFX(EstablishStackFsp):
 \r
   push      DATA_LEN_OF_MCUD     ; Size of the data region\r
   push      4455434Dh            ; Signature of the  data region 'MCUD'\r
-  push      dword [edx + 2Ch]    ; Code size       sizeof(FSPT_UPD_COMMON) + 12\r
-  push      dword [edx + 28h]    ; Code base       sizeof(FSPT_UPD_COMMON) + 8\r
-  push      dword [edx + 24h]    ; Microcode size  sizeof(FSPT_UPD_COMMON) + 4\r
-  push      dword [edx + 20h]    ; Microcode base  sizeof(FSPT_UPD_COMMON) + 0\r
 \r
+  ; check UPD structure revision (edx + 8)\r
+  cmp       byte [edx + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2\r
+  jae       Fsp22UpdHeader2\r
+\r
+  ; UPD structure is compliant with FSP spec 2.0/2.1\r
+  push      dword [edx + LoadMicrocodeParams.CodeRegionSize]     ; Code size       sizeof(FSPT_UPD_COMMON) + 12\r
+  push      dword [edx + LoadMicrocodeParams.CodeRegionBase]     ; Code base       sizeof(FSPT_UPD_COMMON) + 8\r
+  push      dword [edx + LoadMicrocodeParams.MicrocodeCodeSize]  ; Microcode size  sizeof(FSPT_UPD_COMMON) + 4\r
+  push      dword [edx + LoadMicrocodeParams.MicrocodeCodeAddr]  ; Microcode base  sizeof(FSPT_UPD_COMMON) + 0\r
+  jmp       ContinueAfterUpdPush\r
+\r
+Fsp22UpdHeader2:\r
+  ; UPD structure is compliant with FSP spec 2.2\r
+  push      dword [edx + LoadMicrocodeParamsFsp22.CodeRegionSize]     ; Code size       sizeof(FSPT_UPD_COMMON) + 12\r
+  push      dword [edx + LoadMicrocodeParamsFsp22.CodeRegionBase]     ; Code base       sizeof(FSPT_UPD_COMMON) + 8\r
+  push      dword [edx + LoadMicrocodeParamsFsp22.MicrocodeCodeSize]  ; Microcode size  sizeof(FSPT_UPD_COMMON) + 4\r
+  push      dword [edx + LoadMicrocodeParamsFsp22.MicrocodeCodeAddr]  ; Microcode base  sizeof(FSPT_UPD_COMMON) + 0\r
+\r
+ContinueAfterUpdPush:\r
   ;\r
   ; Save API entry/exit timestamp into stack\r
   ;\r
index ed40f9538ce6fb697629a0c6f28edb5b75a6dd98..5e488c452a853b81610a74e6b262002db89b61ce 100644 (file)
@@ -99,12 +99,35 @@ typedef struct {
   ///\r
   UINT64                      Signature;\r
   ///\r
-  /// Revision of the Data structure. For FSP v2.0 value is 1.\r
+  /// Revision of the Data structure.\r
+  ///   For FSP spec 2.0/2.1 value is 1.\r
+  ///   For FSP spec 2.2 value is 2.\r
   ///\r
   UINT8                       Revision;\r
   UINT8                       Reserved[23];\r
 } FSP_UPD_HEADER;\r
 \r
+///\r
+/// FSPT_ARCH_UPD Configuration.\r
+///\r
+typedef struct {\r
+  ///\r
+  /// Revision Revision of the structure is 1 for this version of the specification.\r
+  ///\r
+  UINT8                       Revision;\r
+  UINT8                       Reserved[3];\r
+  ///\r
+  /// Length Length of the structure in bytes. The current value for this field is 32.\r
+  ///\r
+  UINT32                      Length;\r
+  ///\r
+  /// FspDebugHandler Optional debug handler for the bootloader to receive debug messages\r
+  /// occurring during FSP execution.\r
+  ///\r
+  FSP_DEBUG_HANDLER           FspDebugHandler;\r
+  UINT8                       Reserved1[20];\r
+} FSPT_ARCH_UPD;\r
+\r
 ///\r
 /// FSPM_ARCH_UPD Configuration.\r
 ///\r
@@ -146,6 +169,32 @@ typedef struct {
   UINT8                       Reserved1[4];\r
 } FSPM_ARCH_UPD;\r
 \r
+typedef struct {\r
+  ///\r
+  /// Revision Revision of the structure is 1 for this version of the specification.\r
+  ///\r
+  UINT8                      Revision;\r
+  UINT8                      Reserved[3];\r
+  ///\r
+  /// Length Length of the structure in bytes. The current value for this field is 32.\r
+  ///\r
+  UINT32                      Length;\r
+  ///\r
+  /// FspEventHandler Optional event handler for the bootloader to be informed of events\r
+  /// occurring during FSP execution.\r
+  ///\r
+  FSP_EVENT_HANDLER           FspEventHandler;\r
+  ///\r
+  /// A FSP binary may optionally implement multi-phase silicon initialization,\r
+  /// This is only supported if the FspMultiPhaseSiInitEntryOffset field in FSP_INFO_HEADER\r
+  /// is non-zero.\r
+  /// To enable multi-phase silicon initialization, the bootloader must set\r
+  /// EnableMultiPhaseSiliconInit to a non-zero value.\r
+  ///\r
+  UINT8                       EnableMultiPhaseSiliconInit;\r
+  UINT8                       Reserved1[19];\r
+} FSPS_ARCH_UPD;\r
+\r
 ///\r
 /// FSPT_UPD_COMMON Configuration.\r
 ///\r
@@ -156,6 +205,21 @@ typedef struct {
   FSP_UPD_HEADER              FspUpdHeader;\r
 } FSPT_UPD_COMMON;\r
 \r
+///\r
+/// FSPT_UPD_COMMON Configuration for FSP spec. 2.2 and above.\r
+///\r
+typedef struct {\r
+  ///\r
+  /// FSP_UPD_HEADER Configuration.\r
+  ///\r
+  FSP_UPD_HEADER              FspUpdHeader;\r
+\r
+  ///\r
+  /// FSPT_ARCH_UPD Configuration.\r
+  ///\r
+  FSPT_ARCH_UPD               FsptArchUpd;\r
+} FSPT_UPD_COMMON_FSP22;\r
+\r
 ///\r
 /// FSPM_UPD_COMMON Configuration.\r
 ///\r
@@ -180,6 +244,21 @@ typedef struct {
   FSP_UPD_HEADER              FspUpdHeader;\r
 } FSPS_UPD_COMMON;\r
 \r
+///\r
+/// FSPS_UPD_COMMON Configuration for FSP spec. 2.2 and above.\r
+///\r
+typedef struct {\r
+  ///\r
+  /// FSP_UPD_HEADER Configuration.\r
+  ///\r
+  FSP_UPD_HEADER              FspUpdHeader;\r
+\r
+  ///\r
+  /// FSPS_ARCH_UPD Configuration.\r
+  ///\r
+  FSPS_ARCH_UPD               FspsArchUpd;\r
+} FSPS_UPD_COMMON_FSP22;\r
+\r
 ///\r
 /// Enumeration of FSP_INIT_PHASE for NOTIFY_PHASE.\r
 ///\r
index d1d6901bc3672ce62fd1d559eef22d2063290189..e6c15108f5c540bcb5c27ba2e39541e093361811 100644 (file)
@@ -1175,7 +1175,7 @@ EndList
         UpdRegionCheck = ['FSPT', 'FSPM', 'FSPS']     # FSPX_UPD_REGION\r
         UpdConfigCheck = ['FSP_T', 'FSP_M', 'FSP_S']  # FSP_X_CONFIG, FSP_X_TEST_CONFIG, FSP_X_RESTRICTED_CONFIG\r
         UpdSignatureCheck = ['FSPT_UPD_SIGNATURE', 'FSPM_UPD_SIGNATURE', 'FSPS_UPD_SIGNATURE']\r
-        ExcludedSpecificUpd = 'FSPM_ARCH_UPD'\r
+        ExcludedSpecificUpd = ['FSPT_ARCH_UPD', 'FSPM_ARCH_UPD', 'FSPS_ARCH_UPD']\r
 \r
         if InputHeaderFile != '':\r
             if not os.path.exists(InputHeaderFile):\r
@@ -1229,7 +1229,7 @@ EndList
                 if Match:\r
                     StartIndex = Index - 1\r
                 Match = re.match("}\s([_A-Z0-9]+);", Line)\r
-                if Match and (UpdRegionCheck[item] in Match.group(1) or UpdConfigCheck[item] in Match.group(1)) and (ExcludedSpecificUpd not in Match.group(1)):\r
+                if Match and (UpdRegionCheck[item] in Match.group(1) or UpdConfigCheck[item] in Match.group(1)) and (ExcludedSpecificUpd[item] not in Match.group(1)):\r
                     EndIndex = Index\r
                     StructStart.append(StartIndex)\r
                     StructEnd.append(EndIndex)\r
@@ -1466,7 +1466,7 @@ EndList
 \r
 \r
 def Usage():\r
-    print ("GenCfgOpt Version 0.54")\r
+    print ("GenCfgOpt Version 0.55")\r
     print ("Usage:")\r
     print ("    GenCfgOpt  UPDTXT  PlatformDscFile BuildFvDir                 [-D Macros]")\r
     print ("    GenCfgOpt  HEADER  PlatformDscFile BuildFvDir  InputHFile     [-D Macros]")\r