\r
LIST_ENTRY mDevicePathStack = INITIALIZE_LIST_HEAD_VARIABLE (mDevicePathStack);\r
\r
-\r
-/**\r
- Installs the Platform Driver Override Protocol.\r
-\r
- This function installs the Platform Driver Override Protocol, and ensure there is only one\r
- Platform Driver Override Protocol in the system.\r
-\r
- @param gPlatformDriverOverride PlatformDriverOverride protocol interface which\r
- needs to be installed\r
-\r
- @retval EFI_SUCCESS The protocol is installed successfully.\r
- @retval EFI_ALREADY_STARTED There has been a Platform Driver Override\r
- Protocol in the system, cannot install it again.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InstallPlatformDriverOverrideProtocol (\r
- EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *gPlatformDriverOverride\r
- )\r
-{\r
- EFI_HANDLE Handle;\r
- EFI_STATUS Status;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuffer;\r
-\r
- //\r
- // According to UEFI spec, there can be at most a single instance\r
- // in the system of the EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL.\r
- // So here we check the existence.\r
- //\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiPlatformDriverOverrideProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
- //\r
- // If there was no error, assume there is an installation and return error\r
- //\r
- if (!EFI_ERROR (Status)) {\r
- if (HandleBuffer != NULL) {\r
- FreePool (HandleBuffer);\r
- }\r
- return EFI_ALREADY_STARTED;\r
- }\r
-\r
- //\r
- // Install platform driver override protocol\r
- //\r
- Handle = NULL;\r
- Status = gBS->InstallProtocolInterface (\r
- &Handle,\r
- &gEfiPlatformDriverOverrideProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- gPlatformDriverOverride\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
/**\r
Free all the mapping database memory resource and initialize the mapping list entry.\r
\r
// large mapping infos.\r
// The variable(s) name rule is PlatDriOver, PlatDriOver1, PlatDriOver2, ....\r
//\r
- UINT32 NotEnd;\r
+ UINT32 NotEnd; //Zero is the last one.\r
//\r
// The entry which contains the mapping that Controller Device Path to a set of Driver Device Paths\r
// There are often multi mapping entries in a variable.\r
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
......\r
+ UINT32 NotEnd; //Zero is the last one.\r
UINT32 SIGNATURE;\r
UINT32 DriverNum;\r
EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];\r
Corrupted = FALSE;\r
do {\r
VariableIndex = VariableBuffer;\r
+ //\r
+ // End flag\r
+ //\r
NotEnd = *(UINT32*) VariableIndex;\r
//\r
// Traverse the entries containing the mapping that Controller Device Path\r
return NeededSize;\r
}\r
\r
+/**\r
+ Deletes all environment variable(s) that contain the override mappings from Controller Device Path to\r
+ a set of Driver Device Paths.\r
+\r
+ @retval EFI_SUCCESS Delete all variable(s) successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DeleteOverridesVariables (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *VariableBuffer;\r
+ UINTN VariableNum;\r
+ UINTN BufferSize;\r
+ UINTN Index;\r
+ CHAR16 OverrideVariableName[40];\r
+\r
+ //\r
+ // Get environment variable(s) number\r
+ //\r
+ VariableNum = 0;\r
+ VariableBuffer = GetVariableAndSize (L"PlatDriOver", &gEfiOverrideVariableGuid, &BufferSize);\r
+ VariableNum++;\r
+ if (VariableBuffer == NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ //\r
+ // Check NotEnd to get all PlatDriOverX variable(s)\r
+ //\r
+ while ((*(UINT32*)VariableBuffer) != 0) {\r
+ UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", VariableNum);\r
+ VariableBuffer = GetVariableAndSize (OverrideVariableName, &gEfiOverrideVariableGuid, &BufferSize);\r
+ VariableNum++;\r
+ ASSERT (VariableBuffer != NULL);\r
+ }\r
+\r
+ //\r
+ // Delete PlatDriOver and all additional variables, if exist.\r
+ //\r
+ Status = gRT->SetVariable (\r
+ L"PlatDriOver",\r
+ &gEfiOverrideVariableGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ 0,\r
+ NULL\r
+ );\r
+ ASSERT (!EFI_ERROR (Status));\r
+ for (Index = 1; Index < VariableNum; Index++) {\r
+ UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", Index);\r
+ Status = gRT->SetVariable (\r
+ OverrideVariableName,\r
+ &gEfiOverrideVariableGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ 0,\r
+ NULL\r
+ );\r
+ ASSERT (!EFI_ERROR (Status));\r
+ }\r
+ return EFI_SUCCESS;\r
+}\r
\r
\r
/**\r
Retrieves the image handle of the platform override driver for a controller in\r
the system from the memory mapping database.\r
\r
- @param This A pointer to the\r
- EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.\r
@param ControllerHandle The device handle of the controller to check if\r
a driver override exists.\r
@param DriverImageHandle On input, the previously returnd driver image handle.\r
EFI_STATUS\r
EFIAPI\r
GetDriverFromMapping (\r
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This,\r
IN EFI_HANDLE ControllerHandle,\r
IN OUT EFI_HANDLE *DriverImageHandle,\r
IN LIST_ENTRY *MappingDataBase,\r
return EFI_SUCCESS;\r
}\r
\r
-\r
-/**\r
- Deletes all environment variable(s) that contain the override mappings from Controller Device Path to\r
- a set of Driver Device Paths.\r
-\r
- @retval EFI_SUCCESS Delete all variable(s) successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DeleteOverridesVariables (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- VOID *VariableBuffer;\r
- UINTN VariableNum;\r
- UINTN BufferSize;\r
- UINTN Index;\r
- CHAR16 OverrideVariableName[40];\r
-\r
- //\r
- // Get environment variable(s) number\r
- //\r
- VariableNum = 0;\r
- VariableBuffer = GetVariableAndSize (L"PlatDriOver", &gEfiOverrideVariableGuid, &BufferSize);\r
- VariableNum++;\r
- if (VariableBuffer == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
- //\r
- // Check NotEnd to get all PlatDriOverX variable(s)\r
- //\r
- while ((*(UINT32*)VariableBuffer) != 0) {\r
- UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", VariableNum);\r
- VariableBuffer = GetVariableAndSize (OverrideVariableName, &gEfiOverrideVariableGuid, &BufferSize);\r
- VariableNum++;\r
- ASSERT (VariableBuffer != NULL);\r
- }\r
-\r
- //\r
- // Delete PlatDriOver and all additional variables, if exist.\r
- //\r
- Status = gRT->SetVariable (\r
- L"PlatDriOver",\r
- &gEfiOverrideVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- 0,\r
- NULL\r
- );\r
- ASSERT (!EFI_ERROR (Status));\r
- for (Index = 1; Index < VariableNum; Index++) {\r
- UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", Index);\r
- Status = gRT->SetVariable (\r
- OverrideVariableName,\r
- &gEfiOverrideVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- 0,\r
- NULL\r
- );\r
- ASSERT (!EFI_ERROR (Status));\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
/**\r
Push a controller device path into a globle device path list.\r
\r