public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
To: edk2-devel@lists.01.org
Cc: leif.lindholm@linaro.org, michael.d.kinney@intel.com,
	liming.gao@intel.com, achin.gupta@arm.com,
	supreeth.venkatesh@arm.com, felixp@ami.com,
	jbrasen@qti.qualcomm.com, jonathan.zhang@cavium.com,
	Jiewen Yao <jiewen.yao@intel.com>
Subject: [PATCH v5 03/10] BaseTools/AutoGen: auto generate MM template APIs and dependencies.
Date: Mon, 26 Jun 2017 17:47:39 +0100	[thread overview]
Message-ID: <1498495666-32452-4-git-send-email-supreeth.venkatesh@arm.com> (raw)
In-Reply-To: <1498495666-32452-1-git-send-email-supreeth.venkatesh@arm.com>

This patch adds changes to auto generate MM_CORE_STANDALONE and
MM_STANDALONE Entry Point templates.
Also, it adds changes to help auto generate dependency expressions for
MM_STANDALONE modules.

PI Specification v1.5 specifies Management Mode System Table (MMST)
which is  a collection of common services for managing
MMRAM allocation and providing basic I/O services. MMST is similar to
the UEFI System Table. (Currently, EFI_SMM_SYSTEM_TABLE2 defines
Management Mode System Table)

Some of auto generated MM_CORE_STANDALONE and MM_STANDALONE template
APIs use MMST as parameter.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
---
 BaseTools/Source/Python/AutoGen/GenC.py     | 148 +++++++++++++++++++++++++++-
 BaseTools/Source/Python/AutoGen/GenDepex.py |  17 +++-
 2 files changed, 162 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 67aaef7..7aa2016 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -237,6 +237,100 @@ ProcessModuleEntryPointList (
 ${END}
 """)
 
+## MM_CORE_STANDALONE Entry Point Templates
+gMmCoreStandaloneEntryPointPrototype = TemplateString("""
+${BEGIN}
+EFI_STATUS
+EFIAPI
+${Function} (
+  IN VOID *HobStart
+  );
+${END}
+""")
+
+gMmCoreStandaloneEntryPointString = TemplateString("""
+${BEGIN}
+const UINT32 _gMmRevision = ${PiSpecVersion};
+
+VOID
+EFIAPI
+ProcessModuleEntryPointList (
+  IN VOID *HobStart
+  )
+{
+  ${Function} (HobStart);
+}
+${END}
+""")
+
+## MM_STANDALONE Entry Point Templates
+gMmStandaloneEntryPointPrototype = TemplateString("""
+${BEGIN}
+EFI_STATUS
+EFIAPI
+${Function} (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable
+  );
+${END}
+""")
+
+gMmStandaloneEntryPointString = [
+TemplateString("""
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision = ${PiSpecVersion};
+
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable
+  )
+
+{
+  return EFI_SUCCESS;
+}
+"""),
+TemplateString("""
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision = ${PiSpecVersion};
+${BEGIN}
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable
+  )
+
+{
+  return ${Function} (ImageHandle, MmSystemTable);
+}
+${END}
+"""),
+TemplateString("""
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision = ${PiSpecVersion};
+
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable
+  )
+
+{
+  EFI_STATUS  Status;
+  EFI_STATUS  CombinedStatus;
+
+  CombinedStatus = EFI_LOAD_ERROR;
+${BEGIN}
+  Status = ${Function} (ImageHandle, MmSystemTable);
+  if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {
+    CombinedStatus = Status;
+  }
+${END}
+  return CombinedStatus;
+}
+""")
+]
+
 ## DXE SMM Entry Point Templates
 gDxeSmmEntryPointPrototype = TemplateString("""
 ${BEGIN}
@@ -580,6 +674,15 @@ ${Function} (
   IN EFI_SYSTEM_TABLE  *SystemTable
   );${END}
 """),
+
+'MM'   : TemplateString("""${BEGIN}
+EFI_STATUS
+EFIAPI
+${Function} (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SMM_SYSTEM_TABLE2  *MmSystemTable
+  );${END}
+"""),
 }
 
 gLibraryStructorCall = {
@@ -597,6 +700,11 @@ gLibraryStructorCall = {
   Status = ${Function} (ImageHandle, SystemTable);
   ASSERT_EFI_ERROR (Status);${END}
 """),
+
+'MM'   : TemplateString("""${BEGIN}
+  Status = ${Function} (ImageHandle, MmSystemTable);
+  ASSERT_EFI_ERROR (Status);${END}
+"""),
 }
 
 ## Library Constructor and Destructor Templates
@@ -644,6 +752,21 @@ ${BEGIN}  EFI_STATUS  Status;
 ${FunctionCall}${END}
 }
 """),
+
+'MM'   :   TemplateString("""
+${BEGIN}${FunctionPrototype}${END}
+
+VOID
+EFIAPI
+ProcessLibrary${Type}List (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SMM_SYSTEM_TABLE2  *MmSystemTable
+  )
+{
+${BEGIN}  EFI_STATUS  Status;
+${FunctionCall}${END}
+}
+"""),
 }
 
 gBasicHeaderFile = "Base.h"
@@ -661,6 +784,8 @@ gModuleTypeHeaderFile = {
     "UEFI_DRIVER"       :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"],
     "UEFI_APPLICATION"  :   ["Uefi.h",  "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"],
     "SMM_CORE"          :   ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"],
+    "MM_STANDALONE"     :   ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"],
+    "MM_CORE_STANDALONE" :  ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"],
     "USER_DEFINED"      :   [gBasicHeaderFile]
 }
 
@@ -1266,6 +1391,9 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
             ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
             ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
+        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+            ConstructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))
+            ConstructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))
 
     if str(ConstructorPrototypeString) == '':
         ConstructorPrototypeList = []
@@ -1291,6 +1419,8 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
         elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
                                  'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
+        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+            AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
 
 ## Create code for library destructor
 #
@@ -1323,6 +1453,9 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
                                 'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION', 'SMM_CORE']:
             DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict))
             DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict))
+        elif Lib.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+            DestructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict))
+            DestructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict))
 
     if str(DestructorPrototypeString) == '':
         DestructorPrototypeList = []
@@ -1348,6 +1481,8 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
         elif Info.ModuleType in ['DXE_CORE','DXE_DRIVER','DXE_SMM_DRIVER','DXE_RUNTIME_DRIVER',
                                  'DXE_SAL_DRIVER','UEFI_DRIVER','UEFI_APPLICATION','SMM_CORE']:
             AutoGenC.Append(gLibraryString['DXE'].Replace(Dict))
+        elif Info.ModuleType in ['MM_STANDALONE','MM_CORE_STANDALONE']:
+            AutoGenC.Append(gLibraryString['MM'].Replace(Dict))
 
 
 ## Create code for ModuleEntryPoint
@@ -1377,7 +1512,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
         'UefiSpecVersion':   UefiSpecVersion + 'U'
     }
 
-    if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE']:
+    if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_STANDALONE']:
         if Info.SourceFileList <> None and Info.SourceFileList <> []:
           if NumEntryPoints != 1:
               EdkLogger.error(
@@ -1396,6 +1531,9 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
     elif Info.ModuleType == 'SMM_CORE':
         AutoGenC.Append(gSmmCoreEntryPointString.Replace(Dict))
         AutoGenH.Append(gSmmCoreEntryPointPrototype.Replace(Dict))
+    elif Info.ModuleType == 'MM_CORE_STANDALONE':
+        AutoGenC.Append(gMmCoreStandaloneEntryPointString.Replace(Dict))
+        AutoGenH.Append(gMmCoreStandaloneEntryPointPrototype.Replace(Dict))
     elif Info.ModuleType == 'PEIM':
         if NumEntryPoints < 2:
             AutoGenC.Append(gPeimEntryPointString[NumEntryPoints].Replace(Dict))
@@ -1413,7 +1551,13 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
             AutoGenC.Append(gDxeSmmEntryPointString[0].Replace(Dict))
         else:
             AutoGenC.Append(gDxeSmmEntryPointString[1].Replace(Dict))
-        AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict))    
+        AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict))
+    elif Info.ModuleType == 'MM_STANDALONE':
+        if NumEntryPoints < 2:
+            AutoGenC.Append(gMmStandaloneEntryPointString[NumEntryPoints].Replace(Dict))
+        else:
+            AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict))
+        AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict))
     elif Info.ModuleType == 'UEFI_APPLICATION':
         if NumEntryPoints < 2:
             AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoints].Replace(Dict))
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index 5923a75..7aa22bd 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -42,6 +42,8 @@ gType2Phase = {
     "UEFI_DRIVER"       :   "DXE",
     "UEFI_APPLICATION"  :   "DXE",
     "SMM_CORE"          :   "DXE",
+    "MM_STANDALONE"     :   "MM",
+    "MM_CORE_STANDALONE" :  "MM",
 }
 
 ## Convert dependency expression string into EFI internal representation
@@ -98,6 +100,19 @@ class DependencyExpression:
             "FALSE" :   0x07,
             "END"   :   0x08,
             "SOR"   :   0x09
+        },
+
+        "MM"   : {
+            "BEFORE":   0x00,
+            "AFTER" :   0x01,
+            "PUSH"  :   0x02,
+            "AND"   :   0x03,
+            "OR"    :   0x04,
+            "NOT"   :   0x05,
+            "TRUE"  :   0x06,
+            "FALSE" :   0x07,
+            "END"   :   0x08,
+            "SOR"   :   0x09
         }
     }
 
@@ -289,7 +304,7 @@ class DependencyExpression:
             return
 
         # don't generate depex if all operands are architecture protocols
-        if self.ModuleType in ['UEFI_DRIVER', 'DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER'] and \
+        if self.ModuleType in ['UEFI_DRIVER', 'DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER', 'MM_STANDALONE'] and \
            Op == 'AND' and \
            self.ArchProtocols == set([GuidStructureStringToGuidString(Guid) for Guid in AllOperand]):
             self.PostfixNotation = []
-- 
2.7.4



  parent reply	other threads:[~2017-06-26 16:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26 16:47 [PATCH v5 00/10] *** BaseTools: Tools change to support MM Interface in PI v1.5 Specification *** Supreeth Venkatesh
2017-06-26 16:47 ` [PATCH v5 01/10] BaseTools/GenFfs: add FFS file types for MM modules Supreeth Venkatesh
2017-06-29  8:52   ` Gao, Liming
2017-06-26 16:47 ` [PATCH v5 02/10] BaseTools/GenFw: recognize MM file types as EFI Boot Service Drivers Supreeth Venkatesh
2017-06-26 16:47 ` Supreeth Venkatesh [this message]
2017-06-26 16:47 ` [PATCH v5 04/10] BaseTools/Common: add MM Module data types Supreeth Venkatesh
2017-06-26 16:47 ` [PATCH v5 05/10] BaseTools/Common: add support in FDF Parser to parse MM Modules Supreeth Venkatesh
2017-06-26 16:47 ` [PATCH v5 06/10] BaseTools/CommonDataClass: register " Supreeth Venkatesh
2017-06-26 16:47 ` [PATCH v5 07/10] BaseTools/GenFds: register MM Modules and MM FV file types Supreeth Venkatesh
2017-06-26 16:47 ` [PATCH v5 08/10] BaseTools/build: register MM module types with build tools Supreeth Venkatesh
2017-06-26 16:47 ` [PATCH v5 09/10] BaseTools/Workspace: check MM module type compatibility with PI version Supreeth Venkatesh
2017-06-26 16:47 ` [PATCH v5 10/10] BaseTools/Eot: register MM Module types with FFS class Supreeth Venkatesh
2017-06-26 19:47 ` [PATCH v5 00/10] *** BaseTools: Tools change to support MM Interface in PI v1.5 Specification *** Laszlo Ersek
2017-07-07  2:56 ` Zhu, Yonghong
2017-07-07 17:09   ` Supreeth Venkatesh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498495666-32452-4-git-send-email-supreeth.venkatesh@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox