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
This commit is contained in:
qwang12 2008-09-22 09:41:40 +00:00
parent 7f1eba7b99
commit 834a2e41fb
1 changed files with 12 additions and 10 deletions

View File

@ -26,8 +26,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
EFI_BOOT_SERVICES *mBS;
/** /**
This function returns the size, in bytes, This function returns the size, in bytes,
of the device path data structure specified by DevicePath. of the device path data structure specified by DevicePath.
@ -103,15 +101,19 @@ SmmAppendDevicePath (
Size2 = SmmGetDevicePathSize (SecondDevicePath); Size2 = SmmGetDevicePathSize (SecondDevicePath);
Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); 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) { 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 // Over write Src1 EndNode and do the copy
// //
DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); 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; return NewDevicePath;
@ -171,12 +173,12 @@ _ModuleEntryPoint (
// //
// Cache a pointer to the Boot Services Table // Cache a pointer to the Boot Services Table
// //
mBS = SystemTable->BootServices; gBS = SystemTable->BootServices;
// //
// Retrieve the Loaded Image Protocol // Retrieve the Loaded Image Protocol
// //
Status = mBS->HandleProtocol ( Status = gBS->HandleProtocol (
ImageHandle, ImageHandle,
&gEfiLoadedImageProtocolGuid, &gEfiLoadedImageProtocolGuid,
(VOID*)&LoadedImage (VOID*)&LoadedImage
@ -186,7 +188,7 @@ _ModuleEntryPoint (
// //
// Retrieve SMM Base Protocol // Retrieve SMM Base Protocol
// //
Status = mBS->LocateProtocol ( Status = gBS->LocateProtocol (
&gEfiSmmBaseProtocolGuid, &gEfiSmmBaseProtocolGuid,
NULL, NULL,
(VOID **) &SmmBase (VOID **) &SmmBase
@ -205,7 +207,7 @@ _ModuleEntryPoint (
// //
// Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from
// //
Status = mBS->HandleProtocol ( Status = gBS->HandleProtocol (
LoadedImage->DeviceHandle, LoadedImage->DeviceHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
(VOID*)&ImageDevicePath (VOID*)&ImageDevicePath
@ -235,7 +237,7 @@ _ModuleEntryPoint (
// Optionally install the unload handler // Optionally install the unload handler
// //
if (_gDriverUnloadImageCount > 0) { if (_gDriverUnloadImageCount > 0) {
Status = mBS->HandleProtocol ( Status = gBS->HandleProtocol (
ImageHandle, ImageHandle,
&gEfiLoadedImageProtocolGuid, &gEfiLoadedImageProtocolGuid,
(VOID **)&LoadedImage (VOID **)&LoadedImage