]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DriverEntryPoint.c
Replace mBS with gBS from UefiBootServicesTablePointer Lib to avoid library instance...
[mirror_edk2.git] / IntelFrameworkPkg / Library / DxeSmmDriverEntryPoint / DriverEntryPoint.c
index 539adc1345dcfc6a73e94f2a0fb9d3df2a34ef22..38873a0bf9b32edf8a1190adbe0561511c498db9 100644 (file)
@@ -26,8 +26,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>\r
 \r
 \r
-EFI_BOOT_SERVICES  *mBS;\r
-\r
 /**\r
   This function returns the size, in bytes,\r
   of the device path data structure specified by DevicePath.\r
@@ -103,15 +101,19 @@ SmmAppendDevicePath (
   Size2         = SmmGetDevicePathSize (SecondDevicePath);\r
   Size          = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
 \r
-  Status = mBS->AllocatePool (EfiBootServicesData, Size, (VOID **) &NewDevicePath);\r
+  Status = gBS->AllocatePool (EfiBootServicesData, Size, (VOID **) &NewDevicePath);\r
 \r
   if (EFI_SUCCESS == Status) {\r
-    mBS->CopyMem ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1);\r
+    //\r
+    // CopyMem in gBS is used as this service should always be ready. We didn't choose\r
+    // to use a BaseMemoryLib function as such library instance may have constructor.\r
+    //\r
+    gBS->CopyMem ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1);\r
     //\r
     // Over write Src1 EndNode and do the copy\r
     //\r
     DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));\r
-    mBS->CopyMem ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2);\r
+    gBS->CopyMem ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2);\r
   }\r
 \r
   return NewDevicePath;\r
@@ -171,12 +173,12 @@ _ModuleEntryPoint (
   //\r
   // Cache a pointer to the Boot Services Table\r
   //\r
-  mBS = SystemTable->BootServices;\r
+  gBS = SystemTable->BootServices;\r
 \r
   //\r
   // Retrieve the Loaded Image Protocol\r
   //\r
-  Status = mBS->HandleProtocol (\r
+  Status = gBS->HandleProtocol (\r
                   ImageHandle,\r
                   &gEfiLoadedImageProtocolGuid,\r
                   (VOID*)&LoadedImage\r
@@ -186,7 +188,7 @@ _ModuleEntryPoint (
   //\r
   // Retrieve SMM Base Protocol\r
   //\r
-  Status = mBS->LocateProtocol (\r
+  Status = gBS->LocateProtocol (\r
                   &gEfiSmmBaseProtocolGuid,\r
                   NULL,\r
                   (VOID **) &SmmBase\r
@@ -205,7 +207,7 @@ _ModuleEntryPoint (
     //\r
     // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from\r
     //\r
-    Status = mBS->HandleProtocol (\r
+    Status = gBS->HandleProtocol (\r
                     LoadedImage->DeviceHandle,\r
                     &gEfiDevicePathProtocolGuid,\r
                     (VOID*)&ImageDevicePath\r
@@ -235,7 +237,7 @@ _ModuleEntryPoint (
   // Optionally install the unload handler\r
   //\r
   if (_gDriverUnloadImageCount > 0) {\r
-    Status = mBS->HandleProtocol (\r
+    Status = gBS->HandleProtocol (\r
                     ImageHandle,\r
                     &gEfiLoadedImageProtocolGuid,\r
                     (VOID **)&LoadedImage\r