summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2008-01-17 05:56:45 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2008-01-17 05:56:45 +0000
commit3012ce5cf75f938a79c70568595454e27b2f014a (patch)
treed924d6c391796ef7ccc54d743f02d2db49ec0b86 /MdeModulePkg/Library
parentb290614d493ff72fc2a4410d169314e501b7e79e (diff)
downloadedk2-3012ce5cf75f938a79c70568595454e27b2f014a.zip
edk2-3012ce5cf75f938a79c70568595454e27b2f014a.tar.gz
edk2-3012ce5cf75f938a79c70568595454e27b2f014a.tar.bz2
1. Fixed bugs in DxeNetLib to meet consistence with network module DriverBinding protocol.
2. Sync bugs in console modules. 3. Sync bugs in PlatDriOverLib. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4571 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Library')
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.c32
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf16
-rw-r--r--MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c144
3 files changed, 142 insertions, 50 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index f65489e..ee8b679 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -25,6 +25,8 @@ Abstract:
#include <Protocol/SimpleNetwork.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/NicIp4Config.h>
+#include <Protocol/ComponentName.h>
+#include <Protocol/ComponentName2.h>
#include <Library/NetLib.h>
#include <Library/BaseLib.h>
@@ -842,8 +844,7 @@ NetLibDefaultUnload (
UINTN Index;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
- EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
- EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Get the list of all the handles in the handle database.
@@ -912,30 +913,15 @@ NetLibDefaultUnload (
Status = gBS->HandleProtocol (
DeviceHandleBuffer[Index],
- &gEfiDriverConfigurationProtocolGuid,
- (VOID **) &DriverConfiguration
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **) &ComponentName2
);
-
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
- ImageHandle,
- &gEfiDriverConfigurationProtocolGuid,
- DriverConfiguration
- );
- }
-
- Status = gBS->HandleProtocol (
- DeviceHandleBuffer[Index],
- &gEfiDriverDiagnosticsProtocolGuid,
- (VOID **) &DriverDiagnostics
- );
-
- if (!EFI_ERROR (Status)) {
- gBS->UninstallProtocolInterface (
- ImageHandle,
- &gEfiDriverDiagnosticsProtocolGuid,
- DriverDiagnostics
- );
+ ImageHandle,
+ &gEfiComponentName2ProtocolGuid,
+ ComponentName2
+ );
}
}
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
index deb8949..3ce822d 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
@@ -44,15 +44,17 @@
[LibraryClasses]
- BaseLib
- DebugLib
- BaseMemoryLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- UefiLib
- MemoryAllocationLib
+ BaseLib
+ DebugLib
+ BaseMemoryLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiLib
+ MemoryAllocationLib
[Protocols]
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiNicIp4ConfigProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDpcProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED \ No newline at end of file
diff --git a/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c b/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
index d32715b..0ba63fc 100644
--- a/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
+++ b/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
@@ -63,7 +63,7 @@ InstallPlatformDriverOverrideProtocol (
//
if (!EFI_ERROR (Status)) {
if (HandleBuffer != NULL) {
- gBS->FreePool (HandleBuffer);
+ FreePool (HandleBuffer);
}
return EFI_ALREADY_STARTED;
}
@@ -536,6 +536,92 @@ SaveOverridesMapping (
return EFI_SUCCESS;
}
+/**
+ Get the first Binding protocol which has the specific image handle
+
+ @param Image Image handle
+
+ @return Pointer into the Binding Protocol interface
+
+**/
+EFI_DRIVER_BINDING_PROTOCOL *
+EFIAPI
+GetBindingProtocolFromImageHandle (
+ IN EFI_HANDLE ImageHandle,
+ OUT EFI_HANDLE *BindingHandle
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN DriverBindingHandleCount;
+ EFI_HANDLE *DriverBindingHandleBuffer;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBindingInterface;
+
+ if (BindingHandle == NULL || ImageHandle == NULL) {
+ return NULL;
+ }
+ //
+ // Get all driver which support binding protocol in second page
+ //
+ DriverBindingHandleCount = 0;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDriverBindingProtocolGuid,
+ NULL,
+ &DriverBindingHandleCount,
+ &DriverBindingHandleBuffer
+ );
+ if (EFI_ERROR (Status) || (DriverBindingHandleCount == 0)) {
+ return NULL;
+ }
+
+ for (Index = 0; Index < DriverBindingHandleCount; Index++) {
+ DriverBindingInterface =NULL;
+ Status = gBS->OpenProtocol (
+ DriverBindingHandleBuffer[Index],
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **) &DriverBindingInterface,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ if (DriverBindingInterface->ImageHandle == ImageHandle) {
+ *BindingHandle = DriverBindingHandleBuffer[Index];
+ FreePool (DriverBindingHandleBuffer);
+ return DriverBindingInterface;
+ }
+ }
+
+ FreePool (DriverBindingHandleBuffer);
+ *BindingHandle = NULL;
+ return NULL;
+}
+
+/**
+ return the current TPL, copied from the EDKII glue lib
+
+ @param VOID
+
+ @return Current TPL
+
+**/
+EFI_TPL
+GetCurrentTpl (
+ VOID
+ )
+{
+ EFI_TPL Tpl;
+
+ Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
+ gBS->RestoreTPL (Tpl);
+
+ return Tpl;
+}
+
/**
Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.
@@ -582,6 +668,7 @@ GetDriverFromMapping (
UINTN Index;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ EFI_HANDLE DriverBindingHandle;
BOOLEAN FoundLastReturned;
PLATFORM_OVERRIDE_ITEM *OverrideItem;
DRIVER_IMAGE_INFO *DriverImageInfo;
@@ -741,18 +828,27 @@ GetDriverFromMapping (
}
if (ImageFound) {
- Status = gBS->HandleProtocol (
- ImageHandleBuffer[Index],
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding
- );
- ASSERT (!EFI_ERROR (Status));
+ //
+ // Find its related driver binding protocol
+ // Driver binding handle may be different with its driver's Image handle,
+ //
+ DriverBindingHandle = NULL;
+ DriverBinding = GetBindingProtocolFromImageHandle (
+ ImageHandleBuffer[Index],
+ &DriverBindingHandle
+ );
+ ASSERT (DriverBinding != NULL);
DriverImageInfo->ImageHandle = ImageHandleBuffer[Index];
- } else {
+ } else if (GetCurrentTpl() <= TPL_CALLBACK){
//
// The driver image has not been loaded and started, need try to load and start it now
// Try to connect all device in the driver image path
//
+ // Note: LoadImage() and StartImage() should be called under CALLBACK TPL in theory, but
+ // since many device need to be connected in CALLBACK level environment( e.g. Usb devices )
+ // and the Fat and Patition driver can endure executing in CALLBACK level in fact, so here permit
+ // to use LoadImage() and StartImage() in CALLBACK TPL.
+ //
Status = ConnectDevicePath (DriverImageInfo->DriverImagePath);
//
// check whether it points to a PCI Option Rom image, and try to use bus override protocol to get its first option rom image driver
@@ -774,12 +870,16 @@ GetDriverFromMapping (
&ImageHandle
);
if (!EFI_ERROR (Status)) {
- Status = gBS->HandleProtocol (
- ImageHandle,
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding
- );
- ASSERT (!EFI_ERROR (Status));
+ //
+ // Find its related driver binding protocol
+ // Driver binding handle may be different with its driver's Image handle
+ //
+ DriverBindingHandle = NULL;
+ DriverBinding = GetBindingProtocolFromImageHandle (
+ ImageHandle,
+ &DriverBindingHandle
+ );
+ ASSERT (DriverBinding != NULL);
DriverImageInfo->ImageHandle = ImageHandle;
}
}
@@ -814,12 +914,16 @@ GetDriverFromMapping (
DriverImageInfo->UnStartable = TRUE;
DriverImageInfo->ImageHandle = NULL;
} else {
- Status = gBS->HandleProtocol (
- ImageHandle,
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding
- );
- ASSERT (!EFI_ERROR (Status));
+ //
+ // Find its related driver binding protocol
+ // Driver binding handle may be different with its driver's Image handle
+ //
+ DriverBindingHandle = NULL;
+ DriverBinding = GetBindingProtocolFromImageHandle (
+ ImageHandle,
+ &DriverBindingHandle
+ );
+ ASSERT (DriverBinding != NULL);
DriverImageInfo->ImageHandle = ImageHandle;
}
} else {