summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-25 09:13:53 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-25 09:13:53 +0000
commit68dbca6c14afab33f30d43c9956b659c15fa6874 (patch)
treedd4085e9ea65c3fdafb38bdb154df49cbc02af97 /MdeModulePkg/Library
parent97404058f1752da8fa2ba531e592491c65cb29f1 (diff)
downloadedk2-platforms-68dbca6c14afab33f30d43c9956b659c15fa6874.tar.xz
Code Clean for Driver PlatformDriOverrideDxe and PlatOverMngr application. And Clean PlatDriOver library class.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7121 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Library')
-rw-r--r--MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf1
-rw-r--r--MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOver.h3
-rw-r--r--MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c201
-rw-r--r--MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf2
4 files changed, 70 insertions, 137 deletions
diff --git a/MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf b/MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf
index 8dc2e6eacb..f383b140ef 100644
--- a/MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf
+++ b/MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf
@@ -54,7 +54,6 @@
[Protocols]
gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiPlatformDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDriverBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
diff --git a/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOver.h b/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOver.h
index a2e5bf4f67..3d9fb2d724 100644
--- a/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOver.h
+++ b/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOver.h
@@ -19,9 +19,7 @@
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/LoadedImage.h>
-#include <Protocol/PlatformDriverOverride.h>
#include <Protocol/DevicePath.h>
-#include <Protocol/DriverBinding.h>
#include <Protocol/BusSpecificDriverOverride.h>
#include <Library/BaseLib.h>
@@ -37,6 +35,7 @@
#include <Library/PlatDriOverLib.h>
#include <Guid/OverrideVariable.h>
+#include <VariableFormat.h>
#define PLATFORM_OVERRIDE_ITEM_SIGNATURE SIGNATURE_32('p','d','o','i')
diff --git a/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c b/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
index 5f9985f11f..30e5883d7c 100644
--- a/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
+++ b/MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
@@ -16,69 +16,6 @@
LIST_ENTRY mDevicePathStack = INITIALIZE_LIST_HEAD_VARIABLE (mDevicePathStack);
-
-/**
- Installs the Platform Driver Override Protocol.
-
- This function installs the Platform Driver Override Protocol, and ensure there is only one
- Platform Driver Override Protocol in the system.
-
- @param gPlatformDriverOverride PlatformDriverOverride protocol interface which
- needs to be installed
-
- @retval EFI_SUCCESS The protocol is installed successfully.
- @retval EFI_ALREADY_STARTED There has been a Platform Driver Override
- Protocol in the system, cannot install it again.
-
-**/
-EFI_STATUS
-EFIAPI
-InstallPlatformDriverOverrideProtocol (
- EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *gPlatformDriverOverride
- )
-{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
-
- //
- // According to UEFI spec, there can be at most a single instance
- // in the system of the EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL.
- // So here we check the existence.
- //
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPlatformDriverOverrideProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- //
- // If there was no error, assume there is an installation and return error
- //
- if (!EFI_ERROR (Status)) {
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
- return EFI_ALREADY_STARTED;
- }
-
- //
- // Install platform driver override protocol
- //
- Handle = NULL;
- Status = gBS->InstallProtocolInterface (
- &Handle,
- &gEfiPlatformDriverOverrideProtocolGuid,
- EFI_NATIVE_INTERFACE,
- gPlatformDriverOverride
- );
- ASSERT_EFI_ERROR (Status);
- return EFI_SUCCESS;
-}
-
-
/**
Free all the mapping database memory resource and initialize the mapping list entry.
@@ -154,7 +91,7 @@ FreeMappingDatabase (
// large mapping infos.
// The variable(s) name rule is PlatDriOver, PlatDriOver1, PlatDriOver2, ....
//
- UINT32 NotEnd;
+ UINT32 NotEnd; //Zero is the last one.
//
// The entry which contains the mapping that Controller Device Path to a set of Driver Device Paths
// There are often multi mapping entries in a variable.
@@ -166,6 +103,7 @@ FreeMappingDatabase (
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
......
+ UINT32 NotEnd; //Zero is the last one.
UINT32 SIGNATURE;
UINT32 DriverNum;
EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];
@@ -224,6 +162,9 @@ InitOverridesMapping (
Corrupted = FALSE;
do {
VariableIndex = VariableBuffer;
+ //
+ // End flag
+ //
NotEnd = *(UINT32*) VariableIndex;
//
// Traverse the entries containing the mapping that Controller Device Path
@@ -363,6 +304,69 @@ GetOneItemNeededSize (
return NeededSize;
}
+/**
+ Deletes all environment variable(s) that contain the override mappings from Controller Device Path to
+ a set of Driver Device Paths.
+
+ @retval EFI_SUCCESS Delete all variable(s) successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+DeleteOverridesVariables (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *VariableBuffer;
+ UINTN VariableNum;
+ UINTN BufferSize;
+ UINTN Index;
+ CHAR16 OverrideVariableName[40];
+
+ //
+ // Get environment variable(s) number
+ //
+ VariableNum = 0;
+ VariableBuffer = GetVariableAndSize (L"PlatDriOver", &gEfiOverrideVariableGuid, &BufferSize);
+ VariableNum++;
+ if (VariableBuffer == NULL) {
+ return EFI_NOT_FOUND;
+ }
+ //
+ // Check NotEnd to get all PlatDriOverX variable(s)
+ //
+ while ((*(UINT32*)VariableBuffer) != 0) {
+ UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", VariableNum);
+ VariableBuffer = GetVariableAndSize (OverrideVariableName, &gEfiOverrideVariableGuid, &BufferSize);
+ VariableNum++;
+ ASSERT (VariableBuffer != NULL);
+ }
+
+ //
+ // Delete PlatDriOver and all additional variables, if exist.
+ //
+ Status = gRT->SetVariable (
+ L"PlatDriOver",
+ &gEfiOverrideVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ 0,
+ NULL
+ );
+ ASSERT (!EFI_ERROR (Status));
+ for (Index = 1; Index < VariableNum; Index++) {
+ UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", Index);
+ Status = gRT->SetVariable (
+ OverrideVariableName,
+ &gEfiOverrideVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ 0,
+ NULL
+ );
+ ASSERT (!EFI_ERROR (Status));
+ }
+ return EFI_SUCCESS;
+}
/**
@@ -627,8 +631,6 @@ GetCurrentTpl (
Retrieves the image handle of the platform override driver for a controller in
the system from the memory mapping database.
- @param This A pointer to the
- EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.
@param ControllerHandle The device handle of the controller to check if
a driver override exists.
@param DriverImageHandle On input, the previously returnd driver image handle.
@@ -653,7 +655,6 @@ GetCurrentTpl (
EFI_STATUS
EFIAPI
GetDriverFromMapping (
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN OUT EFI_HANDLE *DriverImageHandle,
IN LIST_ENTRY *MappingDataBase,
@@ -1365,72 +1366,6 @@ DeleteDriverImage (
return EFI_SUCCESS;
}
-
-/**
- Deletes all environment variable(s) that contain the override mappings from Controller Device Path to
- a set of Driver Device Paths.
-
- @retval EFI_SUCCESS Delete all variable(s) successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-DeleteOverridesVariables (
- VOID
- )
-{
- EFI_STATUS Status;
- VOID *VariableBuffer;
- UINTN VariableNum;
- UINTN BufferSize;
- UINTN Index;
- CHAR16 OverrideVariableName[40];
-
- //
- // Get environment variable(s) number
- //
- VariableNum = 0;
- VariableBuffer = GetVariableAndSize (L"PlatDriOver", &gEfiOverrideVariableGuid, &BufferSize);
- VariableNum++;
- if (VariableBuffer == NULL) {
- return EFI_NOT_FOUND;
- }
- //
- // Check NotEnd to get all PlatDriOverX variable(s)
- //
- while ((*(UINT32*)VariableBuffer) != 0) {
- UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", VariableNum);
- VariableBuffer = GetVariableAndSize (OverrideVariableName, &gEfiOverrideVariableGuid, &BufferSize);
- VariableNum++;
- ASSERT (VariableBuffer != NULL);
- }
-
- //
- // Delete PlatDriOver and all additional variables, if exist.
- //
- Status = gRT->SetVariable (
- L"PlatDriOver",
- &gEfiOverrideVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- 0,
- NULL
- );
- ASSERT (!EFI_ERROR (Status));
- for (Index = 1; Index < VariableNum; Index++) {
- UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", Index);
- Status = gRT->SetVariable (
- OverrideVariableName,
- &gEfiOverrideVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- 0,
- NULL
- );
- ASSERT (!EFI_ERROR (Status));
- }
- return EFI_SUCCESS;
-}
-
-
/**
Push a controller device path into a globle device path list.
diff --git a/MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf b/MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
index 70ddff17a1..fdce5f3d85 100644
--- a/MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+++ b/MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
@@ -22,7 +22,7 @@
FILE_GUID = e405ec31-ccaa-4dd4-83e8-0aec01703f7e
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = GenericBdsLib|DXE_DRIVER
+ LIBRARY_CLASS = GenericBdsLib|DXE_DRIVER UEFI_APPLICATION
#
# The following information is for reference only and not required by the build tools.