]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Install LoadedImage protocol for PiSmmCore.
authorYao, Jiewen <jiewen.yao@intel.com>
Wed, 25 Nov 2015 08:40:49 +0000 (08:40 +0000)
committerjyao1 <jyao1@Edk2>
Wed, 25 Nov 2015 08:40:49 +0000 (08:40 +0000)
PiSmmCore installs LoadedImage for each SMM driver. However itself is missing.
So we follow DxeCore style, let PiSmmCore installs LoadedImage protocol for itself,
then the SMM image information is complete.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com>
Reviewed-by: "Zeng, Star" <star.zeng@intel.com>
Reviewed-by: "Kinney, Michael D" <michael.d.kinney@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18945 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/PiSmmCore/Dispatcher.c
MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
MdeModulePkg/Core/PiSmmCore/PiSmmCore.h

index cbaf549066e33d51f9bcf59f4f1cebb04a7b4673..1f85ae8def6165ccbf9c88d89c06c7c2ea40b49e 100644 (file)
@@ -103,7 +103,8 @@ BOOLEAN  gRequestDispatch = FALSE;
 //\r
 EFI_FV_FILETYPE mSmmFileTypes[] = {\r
   EFI_FV_FILETYPE_SMM,\r
-  EFI_FV_FILETYPE_COMBINED_SMM_DXE\r
+  EFI_FV_FILETYPE_COMBINED_SMM_DXE,\r
+  EFI_FV_FILETYPE_SMM_CORE,\r
   //\r
   // Note: DXE core will process the FV image file, so skip it in SMM core\r
   // EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
@@ -1283,6 +1284,7 @@ SmmDriverDispatchHandler (
     //\r
     // Discover Drivers in FV and add them to the Discovered Driver List.\r
     // Process EFI_FV_FILETYPE_SMM type and then EFI_FV_FILETYPE_COMBINED_SMM_DXE\r
+    //  EFI_FV_FILETYPE_SMM_CORE is processed to produce a Loaded Image protocol for the core\r
     //\r
     for (SmmTypeIndex = 0; SmmTypeIndex < sizeof (mSmmFileTypes)/sizeof (EFI_FV_FILETYPE); SmmTypeIndex++) {\r
       //\r
@@ -1300,7 +1302,34 @@ SmmDriverDispatchHandler (
                                   &Size\r
                                   );\r
         if (!EFI_ERROR (GetNextFileStatus)) {\r
-          SmmAddToDriverList (Fv, FvHandle, &NameGuid);\r
+          if (Type == EFI_FV_FILETYPE_SMM_CORE) {\r
+            //\r
+            // If this is the SMM core fill in it's DevicePath & DeviceHandle\r
+            //\r
+            if (mSmmCoreLoadedImage->FilePath == NULL) {\r
+              //\r
+              // Maybe one special FV contains only one SMM_CORE module, so its device path must\r
+              // be initialized completely.\r
+              //\r
+              EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, &NameGuid);\r
+              SetDevicePathEndNode (&mFvDevicePath.End);\r
+\r
+              //\r
+              // Make an EfiBootServicesData buffer copy of FilePath\r
+              //\r
+              Status = gBS->AllocatePool (\r
+                              EfiBootServicesData,\r
+                              GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath),\r
+                              (VOID **)&mSmmCoreLoadedImage->FilePath\r
+                              );\r
+              ASSERT_EFI_ERROR (Status);\r
+              CopyMem (mSmmCoreLoadedImage->FilePath, &mFvDevicePath, GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath));\r
+\r
+              mSmmCoreLoadedImage->DeviceHandle = FvHandle;\r
+            }\r
+          } else {\r
+            SmmAddToDriverList (Fv, FvHandle, &NameGuid);\r
+          }\r
         }\r
       } while (!EFI_ERROR (GetNextFileStatus));\r
     }\r
index cc7ccec248c0c321ca970b3cfb81dfcdf92da880..7245f201fbdf78ca965208c2563f67918bc69509 100644 (file)
@@ -87,6 +87,8 @@ SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {
 UINTN                           mFullSmramRangeCount;\r
 EFI_SMRAM_DESCRIPTOR            *mFullSmramRanges;\r
 \r
+EFI_LOADED_IMAGE_PROTOCOL       *mSmmCoreLoadedImage;\r
+\r
 /**\r
   Place holder function until all the SMM System Table Service are available.\r
 \r
@@ -520,6 +522,51 @@ SmmEntryPoint (
   PERF_END (NULL, "SMM", NULL, 0) ;\r
 }\r
 \r
+/**\r
+  Install LoadedImage protocol for SMM Core.\r
+**/\r
+VOID\r
+SmmCoreInstallLoadedImage (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_HANDLE                 Handle;\r
+\r
+  //\r
+  // Allocate a Loaded Image Protocol in EfiBootServicesData\r
+  //\r
+  Status = gBS->AllocatePool (EfiBootServicesData, sizeof(EFI_LOADED_IMAGE_PROTOCOL), (VOID **)&mSmmCoreLoadedImage);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  ZeroMem (mSmmCoreLoadedImage, sizeof (EFI_LOADED_IMAGE_PROTOCOL));\r
+  //\r
+  // Fill in the remaining fields of the Loaded Image Protocol instance.\r
+  // Note: ImageBase is an SMRAM address that can not be accessed outside of SMRAM if SMRAM window is closed.\r
+  //\r
+  mSmmCoreLoadedImage->Revision      = EFI_LOADED_IMAGE_PROTOCOL_REVISION;\r
+  mSmmCoreLoadedImage->ParentHandle  = gSmmCorePrivate->SmmIplImageHandle;\r
+  mSmmCoreLoadedImage->SystemTable   = gST;\r
+\r
+  mSmmCoreLoadedImage->ImageBase     = (VOID *)(UINTN)gSmmCorePrivate->PiSmmCoreImageBase;\r
+  mSmmCoreLoadedImage->ImageSize     = gSmmCorePrivate->PiSmmCoreImageSize;\r
+  mSmmCoreLoadedImage->ImageCodeType = EfiRuntimeServicesCode;\r
+  mSmmCoreLoadedImage->ImageDataType = EfiRuntimeServicesData;\r
+\r
+  //\r
+  // Create a new image handle in the UEFI handle database for the SMM Driver\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiLoadedImageProtocolGuid, mSmmCoreLoadedImage,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return ;\r
+}\r
+\r
 /**\r
   The Entry Point for SMM Core\r
 \r
@@ -586,5 +633,7 @@ SmmMain (
 \r
   RegisterSmramProfileHandler ();\r
 \r
+  SmmCoreInstallLoadedImage ();\r
+\r
   return EFI_SUCCESS;\r
 }\r
index e34bd8a640f3a1261eac452cdb8c6d3e078c1047..0e9c92abef9a78111e12b92ca890a72aefcfb35b 100644 (file)
@@ -959,6 +959,8 @@ SmramProfileReadyToLock (
 extern UINTN                    mFullSmramRangeCount;\r
 extern EFI_SMRAM_DESCRIPTOR     *mFullSmramRanges;\r
 \r
+extern EFI_LOADED_IMAGE_PROTOCOL  *mSmmCoreLoadedImage;\r
+\r
 //\r
 // Page management\r
 //\r