]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenC.py
BaseTools/AutoGen: auto generate MM template APIs and dependencies.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenC.py
index 67aaef70a1b3f3767672527943a6ec874cadb548..7aa2016196d487125886ce6bce4e8314da323058 100644 (file)
@@ -237,6 +237,100 @@ ProcessModuleEntryPointList (
 ${END}\r
 """)\r
 \r
+## MM_CORE_STANDALONE Entry Point Templates\r
+gMmCoreStandaloneEntryPointPrototype = TemplateString("""\r
+${BEGIN}\r
+EFI_STATUS\r
+EFIAPI\r
+${Function} (\r
+  IN VOID *HobStart\r
+  );\r
+${END}\r
+""")\r
+\r
+gMmCoreStandaloneEntryPointString = TemplateString("""\r
+${BEGIN}\r
+const UINT32 _gMmRevision = ${PiSpecVersion};\r
+\r
+VOID\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+  IN VOID *HobStart\r
+  )\r
+{\r
+  ${Function} (HobStart);\r
+}\r
+${END}\r
+""")\r
+\r
+## MM_STANDALONE Entry Point Templates\r
+gMmStandaloneEntryPointPrototype = TemplateString("""\r
+${BEGIN}\r
+EFI_STATUS\r
+EFIAPI\r
+${Function} (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable\r
+  );\r
+${END}\r
+""")\r
+\r
+gMmStandaloneEntryPointString = [\r
+TemplateString("""\r
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision = ${PiSpecVersion};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable\r
+  )\r
+\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+"""),\r
+TemplateString("""\r
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision = ${PiSpecVersion};\r
+${BEGIN}\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable\r
+  )\r
+\r
+{\r
+  return ${Function} (ImageHandle, MmSystemTable);\r
+}\r
+${END}\r
+"""),\r
+TemplateString("""\r
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision = ${PiSpecVersion};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable\r
+  )\r
+\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_STATUS  CombinedStatus;\r
+\r
+  CombinedStatus = EFI_LOAD_ERROR;\r
+${BEGIN}\r
+  Status = ${Function} (ImageHandle, MmSystemTable);\r
+  if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r
+    CombinedStatus = Status;\r
+  }\r
+${END}\r
+  return CombinedStatus;\r
+}\r
+""")\r
+]\r
+\r
 ## DXE SMM Entry Point Templates\r
 gDxeSmmEntryPointPrototype = TemplateString("""\r
 ${BEGIN}\r
@@ -580,6 +674,15 @@ ${Function} (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   );${END}\r
 """),\r
+\r
+'MM'   : TemplateString("""${BEGIN}\r
+EFI_STATUS\r
+EFIAPI\r
+${Function} (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_SMM_SYSTEM_TABLE2  *MmSystemTable\r
+  );${END}\r
+"""),\r
 }\r
 \r
 gLibraryStructorCall = {\r
@@ -597,6 +700,11 @@ gLibraryStructorCall = {
   Status = ${Function} (ImageHandle, SystemTable);\r
   ASSERT_EFI_ERROR (Status);${END}\r
 """),\r
+\r
+'MM'   : TemplateString("""${BEGIN}\r
+  Status = ${Function} (ImageHandle, MmSystemTable);\r
+  ASSERT_EFI_ERROR (Status);${END}\r
+"""),\r
 }\r
 \r
 ## Library Constructor and Destructor Templates\r
@@ -644,6 +752,21 @@ ${BEGIN}  EFI_STATUS  Status;
 ${FunctionCall}${END}\r
 }\r
 """),\r
+\r
+'MM'   :   TemplateString("""\r
+${BEGIN}${FunctionPrototype}${END}\r
+\r
+VOID\r
+EFIAPI\r
+ProcessLibrary${Type}List (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_SMM_SYSTEM_TABLE2  *MmSystemTable\r
+  )\r
+{\r
+${BEGIN}  EFI_STATUS  Status;\r
+${FunctionCall}${END}\r
+}\r
+"""),\r
 }\r
 \r
 gBasicHeaderFile = "Base.h"\r
@@ -661,6 +784,8 @@ gModuleTypeHeaderFile = {
     "UEFI_DRIVER"       :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],\r
     "UEFI_APPLICATION"  :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],\r
     "SMM_CORE"          :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],\r
+    "MM_STANDALONE"     :   ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],\r
+    "MM_CORE_STANDALONE" :  ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],\r
     "USER_DEFINED"      :   [gBasicHeaderFile]\r
 }\r
 \r
@@ -1266,6 +1391,9 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:\r
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))\r
             ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))\r
+        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:\r
+            ConstructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))\r
+            ConstructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))\r
 \r
     if str(ConstructorPrototypeString) == '':\r
         ConstructorPrototypeList = []\r
@@ -1291,6 +1419,8 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
         elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',\r
                                  'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:\r
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))\r
+        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:\r
+            AutoGenC.Append(gLibraryString['MM'].Replace(Dict))\r
 \r
 ## Create code for library destructor\r
 #\r
@@ -1323,6 +1453,9 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']:\r
             DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))\r
             DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))\r
+        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:\r
+            DestructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))\r
+            DestructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))\r
 \r
     if str(DestructorPrototypeString) == '':\r
         DestructorPrototypeList = []\r
@@ -1348,6 +1481,8 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
         elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',\r
                                  'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:\r
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))\r
+        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:\r
+            AutoGenC.Append(gLibraryString['MM'].Replace(Dict))\r
 \r
 \r
 ## Create code for ModuleEntryPoint\r
@@ -1377,7 +1512,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
         'UefiSpecVersion':   UefiSpecVersion + 'U'\r
     }\r
 \r
-    if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE']:\r
+    if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_STANDALONE']:\r
         if Info.SourceFileList <> None and Info.SourceFileList <> []:\r
           if NumEntryPoints != 1:\r
               EdkLogger.error(\r
@@ -1396,6 +1531,9 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
     elif Info.ModuleType == 'SMM_CORE':\r
         AutoGenC.Append(gSmmCoreEntryPointString.Replace(Dict))\r
         AutoGenH.Append(gSmmCoreEntryPointPrototype.Replace(Dict))\r
+    elif Info.ModuleType == 'MM_CORE_STANDALONE':\r
+        AutoGenC.Append(gMmCoreStandaloneEntryPointString.Replace(Dict))\r
+        AutoGenH.Append(gMmCoreStandaloneEntryPointPrototype.Replace(Dict))\r
     elif Info.ModuleType == 'PEIM':\r
         if NumEntryPoints < 2:\r
             AutoGenC.Append(gPeimEntryPointString[NumEntryPoints].Replace(Dict))\r
@@ -1413,7 +1551,13 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
             AutoGenC.Append(gDxeSmmEntryPointString[0].Replace(Dict))\r
         else:\r
             AutoGenC.Append(gDxeSmmEntryPointString[1].Replace(Dict))\r
-        AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict))    \r
+        AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict))\r
+    elif Info.ModuleType == 'MM_STANDALONE':\r
+        if NumEntryPoints < 2:\r
+            AutoGenC.Append(gMmStandaloneEntryPointString[NumEntryPoints].Replace(Dict))\r
+        else:\r
+            AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict))\r
+        AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict))\r
     elif Info.ModuleType == 'UEFI_APPLICATION':\r
         if NumEntryPoints < 2:\r
             AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict))\r