From: qwang12 Date: Mon, 22 Sep 2008 09:41:40 +0000 (+0000) Subject: Replace mBS with gBS from UefiBootServicesTablePointer Lib to avoid library instance... X-Git-Tag: edk2-stable201903~20281 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=834a2e41fb7e3b3aadd0040e1b684caf01f4f4d2 Replace mBS with gBS from UefiBootServicesTablePointer Lib to avoid library instance to cache too many copies of Boot Service Pointer. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5943 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DriverEntryPoint.c b/IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DriverEntryPoint.c index 539adc1345..38873a0bf9 100644 --- a/IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DriverEntryPoint.c +++ b/IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DriverEntryPoint.c @@ -26,8 +26,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include -EFI_BOOT_SERVICES *mBS; - /** This function returns the size, in bytes, of the device path data structure specified by DevicePath. @@ -103,15 +101,19 @@ SmmAppendDevicePath ( Size2 = SmmGetDevicePathSize (SecondDevicePath); Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); - Status = mBS->AllocatePool (EfiBootServicesData, Size, (VOID **) &NewDevicePath); + Status = gBS->AllocatePool (EfiBootServicesData, Size, (VOID **) &NewDevicePath); if (EFI_SUCCESS == Status) { - mBS->CopyMem ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1); + // + // CopyMem in gBS is used as this service should always be ready. We didn't choose + // to use a BaseMemoryLib function as such library instance may have constructor. + // + gBS->CopyMem ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1); // // Over write Src1 EndNode and do the copy // DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); - mBS->CopyMem ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2); + gBS->CopyMem ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2); } return NewDevicePath; @@ -171,12 +173,12 @@ _ModuleEntryPoint ( // // Cache a pointer to the Boot Services Table // - mBS = SystemTable->BootServices; + gBS = SystemTable->BootServices; // // Retrieve the Loaded Image Protocol // - Status = mBS->HandleProtocol ( + Status = gBS->HandleProtocol ( ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID*)&LoadedImage @@ -186,7 +188,7 @@ _ModuleEntryPoint ( // // Retrieve SMM Base Protocol // - Status = mBS->LocateProtocol ( + Status = gBS->LocateProtocol ( &gEfiSmmBaseProtocolGuid, NULL, (VOID **) &SmmBase @@ -205,7 +207,7 @@ _ModuleEntryPoint ( // // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from // - Status = mBS->HandleProtocol ( + Status = gBS->HandleProtocol ( LoadedImage->DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID*)&ImageDevicePath @@ -235,7 +237,7 @@ _ModuleEntryPoint ( // Optionally install the unload handler // if (_gDriverUnloadImageCount > 0) { - Status = mBS->HandleProtocol ( + Status = gBS->HandleProtocol ( ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImage