summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal
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/Universal
parent97404058f1752da8fa2ba531e592491c65cb29f1 (diff)
downloadedk2-68dbca6c14afab33f30d43c9956b659c15fa6874.zip
edk2-68dbca6c14afab33f30d43c9956b659c15fa6874.tar.gz
edk2-68dbca6c14afab33f30d43c9956b659c15fa6874.tar.bz2
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/Universal')
-rw-r--r--MdeModulePkg/Universal/PCD/Pei/Pcd.inf2
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c602
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h224
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf48
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/Vfr.vfr35
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.c187
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.h107
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf18
8 files changed, 501 insertions, 722 deletions
diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.inf b/MdeModulePkg/Universal/PCD/Pei/Pcd.inf
index bb85ab9..01acc1d 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.inf
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.inf
@@ -1,5 +1,5 @@
#/** @file
-# PCD PEIM produces PCD database to manage all dynamic PCD in PEI phase and install Pcd Ppi.
+# PCD PEIM produces PCD database to manage all dynamic PCD in PEI phase and install Pcd Ppi service.
#
# Copyright (c) 2006 - 2008, Intel Corporation
#
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
index 5f49a5b..a55e2ea 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
@@ -15,32 +15,80 @@ Module Name:
Abstract:
- A UI driver to offer a UI interface in device manager to let user configue
+ A UI application to offer a UI interface in device manager to let user configue
platform override protocol to override the default algorithm for matching
drivers to controllers.
The main flow:
- 1. The UI driver dynamicly locate all controller device path.
- 2. The UI driver dynamicly locate all drivers which support binding protocol.
- 3. The UI driver export and dynamicly update two menu to let user select the
+ 1. The UI application dynamicly locate all controller device path.
+ 2. The UI application dynamicly locate all drivers which support binding protocol.
+ 3. The UI application export and dynamicly update two menu to let user select the
mapping between drivers to controllers.
- 4. The UI driver save all the mapping info in NV variables which will be consumed
+ 4. The UI application save all the mapping info in NV variables which will be consumed
by platform override protocol driver to publish the platform override protocol.
**/
+#include <PiDxe.h>
+
+#include <Protocol/HiiConfigAccess.h>
+#include <Protocol/HiiConfigRouting.h>
+#include <Protocol/HiiDatabase.h>
+#include <Protocol/FormBrowser2.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/FirmwareVolume2.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/BusSpecificDriverOverride.h>
+#include <Protocol/ComponentName2.h>
+#include <Protocol/ComponentName.h>
+#include <Protocol/DriverBinding.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiApplicationEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PlatDriOverLib.h>
+#include <Library/HiiLib.h>
+#include <Library/IfrSupportLib.h>
+#include <Library/ExtendedHiiLib.h>
+#include <Library/ExtendedIfrSupportLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/GenericBdsLib.h>
#include "PlatOverMngr.h"
-EFI_GUID mPlatformOverridesManagerGuid = PLAT_OVER_MNGR_GUID;
-
-LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase);
-
-EFI_HANDLE *mDevicePathHandleBuffer;
-EFI_HANDLE *mDriverImageHandleBuffer;
-
-UINTN mSelectedCtrIndex;
-EFI_STRING_ID mControllerToken[MAX_CHOICE_NUM];
-
+#define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')
+#define EFI_CALLBACK_INFO_FROM_THIS(a) CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)
+
+typedef struct {
+ UINTN Signature;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_HANDLE RegisteredHandle;
+ PLAT_OVER_MNGR_DATA FakeNvData;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
+} EFI_CALLBACK_INFO;
+
+//
+// uni string and Vfr Binary data.
+//
+extern UINT8 VfrBin[];
+extern UINT8 PlatOverMngrStrings[];
+
+//
+// module global data
+//
+EFI_GUID mPlatformOverridesManagerGuid = PLAT_OVER_MNGR_GUID;
+LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase);
+
+EFI_HANDLE *mDevicePathHandleBuffer;
+EFI_HANDLE *mDriverImageHandleBuffer;
+
+UINTN mSelectedCtrIndex;
+EFI_STRING_ID mControllerToken[MAX_CHOICE_NUM];
UINTN mDriverImageHandleCount;
EFI_STRING_ID mDriverImageToken[MAX_CHOICE_NUM];
EFI_STRING_ID mDriverImageFilePathToken[MAX_CHOICE_NUM];
@@ -52,212 +100,55 @@ CHAR8 mLanguage[RFC_3066_ENTRY_SIZE];
UINT16 mCurrentPage;
/**
- The driver Entry Point. The funciton will export a disk device class formset and
- its callback function to hii database.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-PlatOverMngrInit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- EFI_CALLBACK_INFO *CallbackInfo;
- EFI_HANDLE DriverHandle;
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
-
- //
- // There should only be one HII protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiHiiDatabaseProtocolGuid,
- NULL,
- (VOID **) &HiiDatabase
- );
- if (EFI_ERROR (Status)) {
- return Status ;
- }
-
-
- //
- // There should only be one Form Configuration protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiFormBrowser2ProtocolGuid,
- NULL,
- (VOID **) &FormBrowser2
- );
- if (EFI_ERROR (Status)) {
- return Status;;
- }
-
-
- CallbackInfo = AllocateZeroPool (sizeof (EFI_CALLBACK_INFO));
- if (CallbackInfo == NULL) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- CallbackInfo->Signature = EFI_CALLBACK_INFO_SIGNATURE;
- CallbackInfo->ConfigAccess.ExtractConfig = PlatOverMngrExtractConfig;
- CallbackInfo->ConfigAccess.RouteConfig = PlatOverMngrRouteConfig;
- CallbackInfo->ConfigAccess.Callback = PlatOverMngrCallback;
-
- //
- // Create driver handle used by HII database
- //
- Status = HiiLibCreateHiiDriverHandle (&DriverHandle);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- CallbackInfo->DriverHandle = DriverHandle;
-
- //
- // Install Config Access protocol to driver handle
- //
- Status = gBS->InstallProtocolInterface (
- &DriverHandle,
- &gEfiHiiConfigAccessProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &CallbackInfo->ConfigAccess
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Publish our HII data
- //
- PackageList = HiiLibPreparePackageList (
- 2,
- &mPlatformOverridesManagerGuid,
- VfrBin,
- PlatOverMngrStrings
- );
- ASSERT (PackageList != NULL);
-
- Status = HiiDatabase->NewPackageList (
- HiiDatabase,
- PackageList,
- DriverHandle,
- &CallbackInfo->RegisteredHandle
- );
- gBS->FreePool (PackageList);
-
- //
- // Locate ConfigRouting protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiHiiConfigRoutingProtocolGuid,
- NULL,
- (VOID **) &CallbackInfo->HiiConfigRouting
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Clear all the globle variable
- //
- mDriverImageHandleCount = 0;
- mCurrentPage = 0;
- ZeroMem (mDriverImageToken, MAX_CHOICE_NUM * sizeof (EFI_STRING_ID));
- ZeroMem (mDriverImageFilePathToken, MAX_CHOICE_NUM * sizeof (EFI_STRING_ID));
- ZeroMem (mControllerToken, MAX_CHOICE_NUM * sizeof (EFI_STRING_ID));
- ZeroMem (mDriverImageProtocol, MAX_CHOICE_NUM * sizeof (EFI_LOADED_IMAGE_PROTOCOL *));
-
- //
- // Show the page
- //
- Status = FormBrowser2->SendForm (
- FormBrowser2,
- &CallbackInfo->RegisteredHandle,
- 1,
- NULL,
- 0,
- NULL,
- NULL
- );
-
- Status = HiiDatabase->RemovePackageList (HiiDatabase, CallbackInfo->RegisteredHandle);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Do some convertion for the ComponentName2 supported language. It do
- the convertion just for english language code currently.
+ Do string convertion for the ComponentName supported language. It do
+ the convertion just for english language code from RFC 3066 to ISO 639-2.
+ Then it will check whether the converted language is in the supported language list.
+ If not supported, NULL is returned.
+ If Language is not english, NULL is returned.
- @param ComponentName Pointer to the ComponentName2 protocl pointer.
- @param Language The language string.
+ @param SupportedLanguages Pointer to ComponentName supported language string list. ISO 639-2 language
+ @param Language The language string. RFC 3066 language
- @return Return the duplication of Language if it is not english otherwise return
- the supported english language code.
+ @return English language string (ISO 639-2)
+ @return NULL if the conertion is not successful.
**/
CHAR8 *
-ConvertComponentName2SupportLanguage (
- IN EFI_COMPONENT_NAME2_PROTOCOL *ComponentName,
+ConvertComponentNameSupportLanguage (
+ IN CHAR8 *SupportedLanguages,
IN CHAR8 *Language
)
{
- CHAR8 *SupportedLanguages;
CHAR8 *LangCode;
- UINTN Index;
-
LangCode = NULL;
- SupportedLanguages = NULL;
//
- // treat all the english language code (en-xx or eng) equally
+ // check the input language is English
//
- if ((AsciiStrnCmp (Language, "en-", 3) == 0) || (AsciiStrCmp (Language, "eng") == 0)) {
- SupportedLanguages = AsciiStrStr (ComponentName->SupportedLanguages, "en");
- if (SupportedLanguages == NULL) {
- SupportedLanguages = AsciiStrStr (ComponentName->SupportedLanguages, "eng");
- }
+ if (AsciiStrnCmp (Language, "en-", 3) != 0) {
+ return NULL;
}
//
- // duplicate the Language if it is not english
+ // Convert Language string from RFC 3066 to ISO 639-2
//
- if (SupportedLanguages == NULL) {
- SupportedLanguages = Language;
- }
-
+ LangCode = AllocateZeroPool(4);
+ AsciiStrCpy (LangCode, "eng");
+
//
- // duplicate the returned language code.
+ // Check whether the converted language is supported in the SupportedLanguages list.
//
- if (AsciiStrStr (SupportedLanguages, "-") != NULL) {
- LangCode = AllocateZeroPool(32);
- for(Index = 0; (Index < 31) && (SupportedLanguages[Index] != '\0') && (SupportedLanguages[Index] != ';'); Index++) {
- LangCode[Index] = SupportedLanguages[Index];
- }
- LangCode[Index] = '\0';
- } else {
- LangCode = AllocateZeroPool(4);
- for(Index = 0; (Index < 3) && (SupportedLanguages[Index] != '\0'); Index++) {
- LangCode[Index] = SupportedLanguages[Index];
- }
- LangCode[Index] = '\0';
+ if (AsciiStrStr (SupportedLanguages, LangCode) == NULL) {
+ FreePool (LangCode);
+ return NULL;
}
+
return LangCode;
}
/**
- Get the ComponentName or ComponentName2 protocol according to the driver binding handle
+ Get the driver name by ComponentName or ComponentName2 protocol
+ according to the driver binding handle
@param DriverBindingHandle The Handle of DriverBinding.
@@ -301,23 +192,24 @@ GetComponentName (
DriverName = NULL;
if (ComponentName != NULL) {
if (ComponentName->GetDriverName != NULL) {
+ SupportedLanguage = ConvertComponentNameSupportLanguage (ComponentName->SupportedLanguages, mLanguage);
Status = ComponentName->GetDriverName (
ComponentName,
- mLanguage,
+ SupportedLanguage,
&DriverName
);
+ FreePool (SupportedLanguage);
}
} else if (ComponentName2 != NULL) {
if (ComponentName2->GetDriverName != NULL) {
- SupportedLanguage = ConvertComponentName2SupportLanguage (ComponentName2, mLanguage);
Status = ComponentName2->GetDriverName (
ComponentName2,
- SupportedLanguage,
+ mLanguage,
&DriverName
);
- gBS->FreePool (SupportedLanguage);
}
}
+
if (EFI_ERROR (Status)) {
return NULL;
}
@@ -326,12 +218,13 @@ GetComponentName (
}
/**
- Get the image name
+ Get the image name from EFI UI section.
+ Get FV protocol by its loaded image protoocl to abastract EFI UI section.
- @param Image Image to search.
+ @param Image Pointer to the loaded image protocol
- @retval !NULL Pointer into the image name if the image name is found,
- @retval NULL Pointer to NULL if the image name is not found.
+ @retval !NULL Pointer to the image name if the image name is found,
+ @retval NULL NULL if the image name is not found.
**/
CHAR16 *
@@ -356,13 +249,8 @@ GetImageName (
if (Image->FilePath == NULL) {
return NULL;
}
-
DevPathNode = Image->FilePath;
- if (DevPathNode == NULL) {
- return NULL;
- }
-
while (!IsDevicePathEnd (DevPathNode)) {
//
// Make sure device path node is aligned when accessing it's FV Name Guid field.
@@ -380,6 +268,9 @@ GetImageName (
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **) &Fv2
);
+ //
+ // Locate Image EFI UI section to get the image name.
+ //
if (!EFI_ERROR (Status)) {
Status = Fv2->ReadSection (
Fv2,
@@ -411,7 +302,9 @@ GetImageName (
/**
Prepare the first page to let user select the device controller which need to
- add mapping drivers.
+ add mapping drivers if user select 'Refresh' in first page.
+ During first page, user will see all currnet controller device path in system,
+ select any device path will go to second page to select its overrides drivers.
@param Private Pointer to EFI_CALLBACK_INFO.
@param KeyValue The callback key value of device controller item in first page.
@@ -439,14 +332,15 @@ UpdateDeviceSelectPage (
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;
UINTN Len;
-
- mCurrentPage = FORM_ID_DEVICE;
+
//
- // Following code will be run if user select 'Refresh' in first page
- // During first page, user will see all currnet controller device path in system,
- // select any device path will go to second page to select its overrides drivers
+ // set current page form ID.
+ //
+ mCurrentPage = FORM_ID_DEVICE;
+
+ //
+ // Get Platform supported Language (RFC_3066 format)
//
-
LangSize = RFC_3066_ENTRY_SIZE;
Status = gRT->GetVariable (
L"PlatformLang",
@@ -484,21 +378,22 @@ UpdateDeviceSelectPage (
//
// When user enter the page at first time, the 'first refresh' string is given to notify user to refresh all the drivers,
- // then the 'first refresh' string will be replaced by the 'refresh' string, and the two strings content are same after the replacement
+ // then the 'first refresh' string will be replaced by the 'refresh' string, and the two strings content are same after the replacement
//
NewStringToken = STRING_TOKEN (STR_FIRST_REFRESH);
HiiLibGetStringFromHandle (Private->RegisteredHandle, STRING_TOKEN (STR_REFRESH), &NewString);
ASSERT (NewString != NULL);
Status = HiiLibSetString (Private->RegisteredHandle, NewStringToken, NewString);
ASSERT_EFI_ERROR (Status);
- gBS->FreePool (NewString);
+ FreePool (NewString);
NewStringToken = STRING_TOKEN (STR_FIRST_REFRESH_HELP);
HiiLibGetStringFromHandle (Private->RegisteredHandle, STRING_TOKEN (STR_REFRESH_HELP), &NewString);
ASSERT (NewString != NULL);
Status = HiiLibSetString (Private->RegisteredHandle, NewStringToken, NewString);
ASSERT_EFI_ERROR (Status);
- gBS->FreePool (NewString);
+ FreePool (NewString);
+
//
// created needed controller device item in first page
//
@@ -587,7 +482,7 @@ UpdateDeviceSelectPage (
Status = HiiLibSetString (Private->RegisteredHandle, NewStringToken, NewString);
}
ASSERT_EFI_ERROR (Status);
- gBS->FreePool (NewString);
+ FreePool (NewString);
//
// Save the device path string toke for next access use
//
@@ -615,11 +510,79 @@ UpdateDeviceSelectPage (
&UpdateData
);
- gBS->FreePool (UpdateData.Data);
+ FreePool (UpdateData.Data);
return EFI_SUCCESS;
}
/**
+ Get the first Driver Binding handle which has the specific image handle.
+
+ @param ImageHandle The Image handle
+
+ @return Handle to Driver binding
+ @retval NULL The paramter is not valid or the driver binding handle is not found.
+
+**/
+EFI_HANDLE
+GetDriverBindingHandleFromImageHandle (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN DriverBindingHandleCount;
+ EFI_HANDLE *DriverBindingHandleBuffer;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBindingInterface;
+ EFI_HANDLE DriverBindingHandle;
+
+ DriverBindingHandle = NULL;
+
+ if (ImageHandle == NULL) {
+ return NULL;
+ }
+ //
+ // Get all drivers which support driver binding protocol
+ //
+ 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) {
+ DriverBindingHandle = DriverBindingHandleBuffer[Index];
+ break;
+ }
+ }
+
+ //
+ // If no Driver Binding Protocol instance is found
+ //
+ FreePool (DriverBindingHandleBuffer);
+ return DriverBindingHandle;
+}
+
+/**
Prepare to let user select the drivers which need mapping with the device controller
selected in first page.
@@ -640,20 +603,17 @@ UpdateBindingDriverSelectPage (
EFI_HII_UPDATE_DATA UpdateData;
EFI_STATUS Status;
UINTN Index;
-
CHAR16 *NewString;
EFI_STRING_ID NewStringToken;
EFI_STRING_ID NewStringHelpToken;
UINTN DriverImageHandleCount;
-
- EFI_DRIVER_BINDING_PROTOCOL *DriverBindingInterface;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
CHAR16 *DriverName;
BOOLEAN FreeDriverName;
-
EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;
EFI_HANDLE DriverBindingHandle;
+
//
// If user select a controller item in the first page the following code will be run.
// During second page, user will see all currnet driver bind protocol driver, the driver name and its device path will be shown
@@ -667,7 +627,7 @@ UpdateBindingDriverSelectPage (
//
// Switch the item callback key value to its NO. in mDevicePathHandleBuffer
//
- mSelectedCtrIndex = KeyValue - 0x100;
+ mSelectedCtrIndex = KeyValue - KEY_VALUE_DEVICE_OFFSET;
ASSERT (mSelectedCtrIndex < MAX_CHOICE_NUM);
mLastSavedDriverImageNum = 0;
//
@@ -731,13 +691,8 @@ UpdateBindingDriverSelectPage (
//
// Find its related driver binding protocol
//
- DriverBindingInterface = NULL;
- DriverBindingHandle = NULL;
- DriverBindingInterface = GetBindingProtocolFromImageHandle (
- mDriverImageHandleBuffer[Index],
- &DriverBindingHandle
- );
- if (DriverBindingInterface == NULL) {
+ DriverBindingHandle = GetDriverBindingHandleFromImageHandle (mDriverImageHandleBuffer[Index]);
+ if (DriverBindingHandle == NULL) {
FakeNvData->DriSelection[Index] = 0x00;
continue;
}
@@ -822,9 +777,9 @@ UpdateBindingDriverSelectPage (
}
mDriverImageToken[Index] = NewStringToken;
ASSERT_EFI_ERROR (Status);
- gBS->FreePool (NewString);
+ FreePool (NewString);
if (FreeDriverName) {
- gBS->FreePool (DriverName);
+ FreePool (DriverName);
}
//
@@ -842,8 +797,8 @@ UpdateBindingDriverSelectPage (
}
mDriverImageFilePathToken[Index] = NewStringHelpToken;
ASSERT_EFI_ERROR (Status);
- gBS->FreePool (NewString);
- gBS->FreePool (DriverName);
+ FreePool (NewString);
+ FreePool (DriverName);
CreateCheckBoxOpCode (
(UINT16) (DRIVER_SELECTION_QUESTION_ID + Index),
@@ -869,7 +824,7 @@ UpdateBindingDriverSelectPage (
&UpdateData
);
- gBS->FreePool (UpdateData.Data);
+ FreePool (UpdateData.Data);
return EFI_SUCCESS;
}
@@ -893,9 +848,7 @@ UpdatePrioritySelectPage (
{
EFI_HII_UPDATE_DATA UpdateData;
UINTN Index;
-
EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
-
IFR_OPTION *IfrOptionList;
UINTN SelectedDriverImageNum;
UINT32 DriverImageNO;
@@ -939,8 +892,8 @@ UpdatePrioritySelectPage (
if (SelectedDriverImageNum == 0) {
return EFI_SUCCESS;
}
-
- IfrOptionList = AllocateZeroPool (0x200);
+
+ IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * mSelectedDriverImageNum);
ASSERT_EFI_ERROR (IfrOptionList != NULL);
//
// Create order list for those selected drivers
@@ -990,7 +943,7 @@ UpdatePrioritySelectPage (
//
// NvRamMap Must be clear firstly
//
- ZeroMem (FakeNvData->DriOrder, 100);
+ ZeroMem (FakeNvData->DriOrder, sizeof (FakeNvData->DriOrder));
//
// Order the selected drivers according to the info already in mapping database
@@ -1010,7 +963,7 @@ UpdatePrioritySelectPage (
// the IfrOptionList[MinNO].Value = the driver NO. in driver binding buffer
//
FakeNvData->DriOrder[Index] =IfrOptionList[MinNO].Value.u8;
- TempNO[MinNO] = 101;
+ TempNO[MinNO] = MAX_CHOICE_NUM + 1;
}
CreateOrderedListOpCode (
@@ -1022,7 +975,7 @@ UpdatePrioritySelectPage (
EFI_IFR_FLAG_RESET_REQUIRED,
0,
EFI_IFR_NUMERIC_SIZE_1,
- 100,
+ MAX_CHOICE_NUM,
IfrOptionList,
SelectedDriverImageNum,
&UpdateData
@@ -1040,8 +993,8 @@ UpdatePrioritySelectPage (
&UpdateData
);
- gBS->FreePool (IfrOptionList);
- gBS->FreePool (UpdateData.Data);
+ FreePool (IfrOptionList);
+ FreePool (UpdateData.Data);
return EFI_SUCCESS;
}
@@ -1124,7 +1077,7 @@ CommintChanges (
EFI_STATUS
EFIAPI
PlatOverMngrExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Request,
OUT EFI_STRING *Progress,
OUT EFI_STRING *Results
@@ -1275,7 +1228,7 @@ PlatOverMngrCallback (
if (((KEY_VALUE_DEVICE_OFFSET <= KeyValue) && (KeyValue < KEY_VALUE_DEVICE_MAX)) || (KeyValue == KEY_VALUE_ORDER_GOTO_PREVIOUS)) {
if (KeyValue == KEY_VALUE_ORDER_GOTO_PREVIOUS) {
- KeyValue = (EFI_QUESTION_ID) (mSelectedCtrIndex + 0x100);
+ KeyValue = (EFI_QUESTION_ID) (mSelectedCtrIndex + KEY_VALUE_DEVICE_OFFSET);
}
UpdateBindingDriverSelectPage (Private, KeyValue, FakeNvData);
//
@@ -1323,41 +1276,144 @@ PlatOverMngrCallback (
}
/**
- Get the description string by device path.
+ The driver Entry Point. The funciton will export a disk device class formset and
+ its callback function to hii database.
- @param DevPath The input device path.
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
- @retval !NULL The description string retured.
- @retval NULL The description string cannot be found.
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
**/
-CHAR16 *
-DevicePathToStr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+EFI_STATUS
+EFIAPI
+PlatOverMngrInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- CHAR16 *ToText;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
+ EFI_STATUS Status;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+ EFI_CALLBACK_INFO *CallbackInfo;
+ EFI_HANDLE DriverHandle;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
- if (DevPath == NULL) {
- return NULL;
+ //
+ // There should only be one HII protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiDatabaseProtocolGuid,
+ NULL,
+ (VOID **) &HiiDatabase
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
}
+ //
+ // There should only be one Form Configuration protocol
+ //
Status = gBS->LocateProtocol (
- &gEfiDevicePathToTextProtocolGuid,
+ &gEfiFormBrowser2ProtocolGuid,
+ NULL,
+ (VOID **) &FormBrowser2
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ CallbackInfo = AllocateZeroPool (sizeof (EFI_CALLBACK_INFO));
+ if (CallbackInfo == NULL) {
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ CallbackInfo->Signature = EFI_CALLBACK_INFO_SIGNATURE;
+ CallbackInfo->ConfigAccess.ExtractConfig = PlatOverMngrExtractConfig;
+ CallbackInfo->ConfigAccess.RouteConfig = PlatOverMngrRouteConfig;
+ CallbackInfo->ConfigAccess.Callback = PlatOverMngrCallback;
+
+ //
+ // Create driver handle used by HII database
+ //
+ Status = HiiLibCreateHiiDriverHandle (&DriverHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ CallbackInfo->DriverHandle = DriverHandle;
+
+ //
+ // Install Config Access protocol to driver handle
+ //
+ Status = gBS->InstallProtocolInterface (
+ &DriverHandle,
+ &gEfiHiiConfigAccessProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &CallbackInfo->ConfigAccess
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Publish our HII data
+ //
+ PackageList = HiiLibPreparePackageList (
+ 2,
+ &mPlatformOverridesManagerGuid,
+ VfrBin,
+ PlatOverMngrStrings
+ );
+ ASSERT (PackageList != NULL);
+
+ Status = HiiDatabase->NewPackageList (
+ HiiDatabase,
+ PackageList,
+ DriverHandle,
+ &CallbackInfo->RegisteredHandle
+ );
+ FreePool (PackageList);
+
+ //
+ // Locate ConfigRouting protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiConfigRoutingProtocolGuid,
NULL,
- (VOID **) &DevPathToText
+ (VOID **) &CallbackInfo->HiiConfigRouting
);
- if (!EFI_ERROR (Status)) {
- ToText = DevPathToText->ConvertDevicePathToText (
- DevPath,
- FALSE,
- TRUE
- );
- ASSERT (ToText != NULL);
- return ToText;
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Clear all the globle variable
+ //
+ mDriverImageHandleCount = 0;
+ mCurrentPage = 0;
+ ZeroMem (mDriverImageToken, MAX_CHOICE_NUM * sizeof (EFI_STRING_ID));
+ ZeroMem (mDriverImageFilePathToken, MAX_CHOICE_NUM * sizeof (EFI_STRING_ID));
+ ZeroMem (mControllerToken, MAX_CHOICE_NUM * sizeof (EFI_STRING_ID));
+ ZeroMem (mDriverImageProtocol, MAX_CHOICE_NUM * sizeof (EFI_LOADED_IMAGE_PROTOCOL *));
+
+ //
+ // Show the page
+ //
+ Status = FormBrowser2->SendForm (
+ FormBrowser2,
+ &CallbackInfo->RegisteredHandle,
+ 1,
+ NULL,
+ 0,
+ NULL,
+ NULL
+ );
+
+ Status = HiiDatabase->RemovePackageList (HiiDatabase, CallbackInfo->RegisteredHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
- return NULL;
+ return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
index d414e7c..a4ebeff 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
@@ -1,4 +1,7 @@
/** @file
+
+ The defintions are required both by Source code and Vfr file.
+ The PLAT_OVER_MNGR_DATA structure, form guid and Ifr question ID are defined.
Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -9,84 +12,29 @@ http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- PlatOverMngr.h
-
-Abstract:
-
- Function prototype for platform driver override manager driver
-
**/
#ifndef _PLAT_OVER_MNGR_H_
#define _PLAT_OVER_MNGR_H_
-#include <PiDxe.h>
-
-#include <Protocol/HiiConfigAccess.h>
-#include <Protocol/HiiConfigRouting.h>
-#include <Protocol/HiiDatabase.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/FirmwareVolumeBlock.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/BusSpecificDriverOverride.h>
-#include <Protocol/ComponentName2.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/DevicePathToText.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiApplicationEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/PlatDriOverLib.h>
-#include <Library/IfrSupportLib.h>
-#include <Library/ExtendedIfrSupportLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/HiiLib.h>
-#include <Library/ExtendedHiiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-
-#define MIN_ALIGNMENT_SIZE 4
-#define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
-
-
-#define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')
-#define EFI_CALLBACK_INFO_FROM_THIS(a) CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)
-#define MAX_CHOICE_NUM 0x100
-#define UPDATE_DATA_SIZE 0x1000
-
-
-extern UINT8 VfrBin[];
-
-extern UINT8 PlatOverMngrStrings[];
-
-//
-// Following definition is the same as in vfr file
-//
#define PLAT_OVER_MNGR_GUID \
{ \
0x8614567d, 0x35be, 0x4415, {0x8d, 0x88, 0xbd, 0x7d, 0xc, 0x9c, 0x70, 0xc0} \
}
-typedef struct {
- UINT8 DriSelection[100];
- UINT8 DriOrder[100];
- UINT8 PciDeviceFilter;
-} PLAT_OVER_MNGR_DATA;
+//
+// The max number of the supported driver list.
+//
+//
+#define MAX_CHOICE_NUM 0x0100
+#define UPDATE_DATA_SIZE 0x1000
-#define FORM_ID_DEVICE 0x1234
+#define FORM_ID_DEVICE 0x1100
#define FORM_ID_DRIVER 0x1200
#define FORM_ID_ORDER 0x1500
#define KEY_VALUE_DEVICE_OFFSET 0x0100
-#define KEY_VALUE_DEVICE_MAX 0x04ff
-
-#define QUESTION_ID_OFFSET 0x0500
+#define KEY_VALUE_DEVICE_MAX (KEY_VALUE_DEVICE_OFFSET + MAX_CHOICE_NUM)
#define KEY_VALUE_DEVICE_REFRESH 0x1234
#define KEY_VALUE_DEVICE_FILTER 0x1235
@@ -100,151 +48,25 @@ typedef struct {
#define VARSTORE_ID_PLAT_OVER_MNGR 0x1000
+typedef struct {
+ UINT8 DriSelection[MAX_CHOICE_NUM];
+ UINT8 DriOrder[MAX_CHOICE_NUM];
+ UINT8 PciDeviceFilter;
+} PLAT_OVER_MNGR_DATA;
+
//
-// Question Id start from 1, so define an offset for it
+// Field offset of structure PLAT_OVER_MNGR_DATA
//
#define VAR_OFFSET(Field) ((UINTN) &(((PLAT_OVER_MNGR_DATA *) 0)->Field))
-
#define DRIVER_SELECTION_VAR_OFFSET (VAR_OFFSET (DriSelection))
#define DRIVER_ORDER_VAR_OFFSET (VAR_OFFSET (DriOrder))
+//
+// Tool automatic generated Question Id start from 1
+// In order to avoid to conflict them, the Driver Selection and Order QuestionID offset is defined from 0x0500.
+//
+#define QUESTION_ID_OFFSET 0x0500
#define DRIVER_SELECTION_QUESTION_ID (VAR_OFFSET (DriSelection) + QUESTION_ID_OFFSET)
#define DRIVER_ORDER_QUESTION_ID (VAR_OFFSET (DriOrder) + QUESTION_ID_OFFSET)
-typedef struct {
- UINTN Signature;
-
- EFI_HANDLE DriverHandle;
- EFI_HII_HANDLE RegisteredHandle;
- PLAT_OVER_MNGR_DATA FakeNvData;
-
- EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
-
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
-} EFI_CALLBACK_INFO;
-
-typedef struct {
- EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
- EFI_HANDLE DriverImageHandle;
- EFI_HANDLE ControllerHandle;
- EFI_HANDLE ChildControllerHandle;
- //
- // To avoid created string leak in Hii database, use this token to reuse every token created by the driver
- //
- EFI_STRING_ID DescriptionToken;
-} CFG_PROTOCOL_INVOKER_CHOICE;
-
-/**
- This function allows a caller to extract the current configuration for one
- or more named elements from the target driver.
-
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
- @param Request A null-terminated Unicode string in <ConfigRequest> format.
- @param Progress On return, points to a character in the Request string.
- Points to the string's null terminator if request was successful.
- Points to the most recent '&' before the first failing name/value
- pair (or the beginning of the string if the failure is in the
- first name/value pair) if the request was not successful.
- @param Results A null-terminated Unicode string in <ConfigAltResp> format which
- has all values filled in for the names in the Request string.
- String to be allocated by the called function.
-
- @retval EFI_SUCCESS The Results is filled with the requested values.
- @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
- @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
-
-**/
-EFI_STATUS
-EFIAPI
-PlatOverMngrExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
- );
-
-/**
- This function processes the results of changes in configuration.
-
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
- @param Configuration A null-terminated Unicode string in <ConfigRequest> format.
- @param Progress A pointer to a string filled in with the offset of the most
- recent '&' before the first failing name/value pair (or the
- beginning of the string if the failure is in the first
- name/value pair) or the terminating NULL if all was successful.
-
- @retval EFI_SUCCESS The Results is processed successfully.
- @retval EFI_INVALID_PARAMETER Configuration is NULL.
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
-
-**/
-EFI_STATUS
-EFIAPI
-PlatOverMngrRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
- );
-
-/**
- This is the function that is called to provide results data to the driver. This data
- consists of a unique key which is used to identify what data is either being passed back
- or being asked for.
-
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
- @param Action A null-terminated Unicode string in <ConfigRequest> format.
- @param KeyValue A unique Goto OpCode callback value which record user's selection.
- 0x100 <= KeyValue <0x500 : user select a controller item in the first page;
- KeyValue == 0x1234 : user select 'Refresh' in first page, or user select 'Go to Previous Menu' in second page
- KeyValue == 0x1235 : user select 'Pci device filter' in first page
- KeyValue == 0x1500 : user select 'order ... priority' item in second page
- KeyValue == 0x1800 : user select 'commint changes' in third page
- KeyValue == 0x2000 : user select 'Go to Previous Menu' in third page
- @param Type The type of value for the question.
- @param Value A pointer to the data being sent to the original exporting driver.
- @param ActionRequest On return, points to the action requested by the callback function.
-
- @retval EFI_SUCCESS Always returned.
-
-**/
-EFI_STATUS
-EFIAPI
-PlatOverMngrCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID KeyValue,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
- );
-
-/**
- Get the image name
-
- @param Image Image to search.
-
- @retval !NULL Pointer into the image name if the image name is found,
- @retval NULL Pointer to NULL if the image name is not found.
-
-**/
-CHAR16 *
-GetImageName (
- IN EFI_LOADED_IMAGE_PROTOCOL *Image
- );
-
-/**
- Get the description string by device path.
-
- @param DevPath The input device path.
-
- @retval !NULL The description string retured.
- @retval NULL The description string cannot be found.
-
-**/
-CHAR16 *
-DevicePathToStr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
- );
-
#endif
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf
index 170c01c..4ba540e 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf
@@ -1,7 +1,17 @@
#/** @file
-# Component description file for PlatOverMngr driver
#
-# FIX ME!
+# A UI application to offer a UI interface in device manager to let user configue
+# platform override protocol to override the default algorithm for matching
+# drivers to controllers.
+#
+# The main flow:
+# 1. The UI application dynamicly locate all controller device path.
+# 2. The UI application dynamicly locate all drivers which support binding protocol.
+# 3. The UI application export and dynamicly update two menu to let user select the
+# mapping between drivers to controllers.
+# 4. The UI application save all the mapping info in NV variables for the following boot,
+# which will be consumed by platform override protocol driver to publish the platform override protocol.
+#
# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
#
# All rights reserved. This program and the accompanying materials
@@ -35,33 +45,43 @@
PlatOverMngr.c
PlatOverMngr.h
-
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
-
[LibraryClasses]
BaseLib
- UefiBootServicesTableLib
- UefiApplicationEntryPoint
- UefiLib
DebugLib
+ UefiLib
+ UefiApplicationEntryPoint
+ UefiBootServicesTableLib
PlatDriOverLib
+ HiiLib
IfrSupportLib
+ ExtendedHiiLib
ExtendedIfrSupportLib
BaseMemoryLib
MemoryAllocationLib
- HiiLib
- ExtendedHiiLib
UefiRuntimeServicesTableLib
DevicePathLib
+ GenericBdsLib
+[Guids]
+ gEfiGlobalVariableGuid # Get value of variable L"PlatformLang".
+ # this value specifies the platform supported language string (RFC 3066)
+
[Protocols]
- gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiHiiConfigAccessProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiDevicePathToTextProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDriverBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiLoadedImageDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiHiiDatabaseProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiFormBrowser2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiHiiConfigRoutingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiHiiConfigAccessProtocolGuid # PROTOCOL ALWAYS_PRODUCED
+ \ No newline at end of file
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/Vfr.vfr b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/Vfr.vfr
index f5514d8..b3cd038 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/Vfr.vfr
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/Vfr.vfr
@@ -1,6 +1,6 @@
// *++
//
-// Copyright (c) 2007, Intel Corporation
+// Copyright (c) 2007 - 2008, Intel Corporation
// All rights reserved. This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at
@@ -20,38 +20,7 @@
//
// --*/
-#define PLAT_OVER_MNGR_GUID \
- { \
- 0x8614567d, 0x35be, 0x4415, 0x8d, 0x88, 0xbd, 0x7d, 0xc, 0x9c, 0x70, 0xc0 \
- }
-
-typedef struct {
- UINT8 DriSelection[100];
- UINT8 DriOrder[100];
- UINT8 PciDeviceFilter;
-} PLAT_OVER_MNGR_DATA;
-
-#define FORM_ID_DEVICE 0x1234
-#define FORM_ID_DRIVER 0x1200
-#define FORM_ID_ORDER 0x1500
-
-#define KEY_VALUE_DEVICE_OFFSET 0x0100
-#define KEY_VALUE_DEVICE_MAX 0x04ff
-
-#define QUESTION_ID_OFFSET 0x0500
-
-#define KEY_VALUE_DEVICE_REFRESH 0x1234
-#define KEY_VALUE_DEVICE_FILTER 0x1235
-#define KEY_VALUE_DEVICE_CLEAR 0x1236
-
-#define KEY_VALUE_DRIVER_GOTO_PREVIOUS 0x1300
-#define KEY_VALUE_DRIVER_GOTO_ORDER 0x1301
-
-#define KEY_VALUE_ORDER_GOTO_PREVIOUS 0x2000
-#define KEY_VALUE_ORDER_SAVE_AND_EXIT 0x1800
-
-#define VARSTORE_ID_PLAT_OVER_MNGR 0x1000
-
+#include "PlatOverMngr.h"
#define EFI_DISK_DEVICE_CLASS 0x01
#define LABEL_END 0xffff
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.c b/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.c
index fd3aee9..aef0f03 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.c
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2007, Intel Corporation
+Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -9,52 +9,20 @@ http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- PlatformDriOverride.c
-
-Abstract:
-
-
**/
+#include <Uefi.h>
-#include "PlatformDriOverride.h"
-
-EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL gPlatformDriverOverride = {
- GetDriver,
- GetDriverPath,
- DriverLoaded
-};
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PlatDriOverLib.h>
+#include <Protocol/PlatformDriverOverride.h>
LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase);
BOOLEAN mEnvironmentVariableRead = FALSE;
-EFI_HANDLE mCallerImageHandle;
-
-/**
- Platform Driver Override driver entry point, install the Platform Driver Override Protocol
-
- @param ImageHandle ImageHandle of the loaded driver.
- @param SystemTable Pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The DXE Driver, DXE Runtime Driver, DXE SMM Driver,
- or UEFI Driver exited normally.
- @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.
- @retval Other Return value from ProcessModuleEntryPointList().
-**/
-EFI_STATUS
-EFIAPI
-PlatformDriverOverrideEntry (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- mEnvironmentVariableRead = FALSE;
- mCallerImageHandle = ImageHandle;
- InitializeListHead (&mMappingDataBase);
- return InstallPlatformDriverOverrideProtocol (&gPlatformDriverOverride);
-}
-
+EFI_HANDLE mCallerImageHandle = NULL;
/**
Retrieves the image handle of the platform override driver for a controller in the system.
@@ -82,12 +50,13 @@ PlatformDriverOverrideEntry (
EFI_STATUS
EFIAPI
GetDriver (
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
+ IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN OUT EFI_HANDLE * DriverImageHandle
+ IN OUT EFI_HANDLE *DriverImageHandle
)
{
EFI_STATUS Status;
+
//
// Check that ControllerHandle is a valid handle
//
@@ -105,59 +74,46 @@ GetDriver (
mEnvironmentVariableRead = TRUE;
Status = InitOverridesMapping (&mMappingDataBase);
- if (Status == EFI_NOT_FOUND) {
- InitializeListHead (&mMappingDataBase);
- return EFI_NOT_FOUND;
- } else if (Status == EFI_VOLUME_CORRUPTED){
- DEBUG ((DEBUG_ERROR, "Platform Driver Override Variable is corrupt\n"));
- //
- // The environment variable(s) that contain the override mappings from Controller Device Path to
- // a set of Driver Device Paths is corrupted, platform code can use LibDeleteOverridesVariables to
- // delete all orverride variables as a policy. Here can be IBV/OEM customized.
- //
-
- //LibDeleteOverridesVariables();
- InitializeListHead (&mMappingDataBase);
- return EFI_NOT_FOUND;
- } else if (EFI_ERROR (Status)){
+ if (EFI_ERROR (Status)){
+ DEBUG ((DEBUG_ERROR, "The status to Get Platform Driver Override Variable is %r\n", Status));
InitializeListHead (&mMappingDataBase);
return EFI_NOT_FOUND;
}
}
+
//
- // if the environment variable does not exist or the variable appears to be corrupt, just return not found
+ // if the environment variable does not exist, just return not found
//
if (IsListEmpty (&mMappingDataBase)) {
return EFI_NOT_FOUND;
}
return GetDriverFromMapping (
- This,
ControllerHandle,
DriverImageHandle,
&mMappingDataBase,
mCallerImageHandle
);
-
}
-
/**
- For the use of the ControllerHandle parameter in the GetDriverPath()
- But this API is very difficult to use, so not support.
-
- @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 DriverImagePath The device path for this Image.
+ Retrieves the device path of the platform override driver for a controller in the system.
+ This driver doesn't support this API.
+
+ @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, a pointer to the previous driver image handle returned
+ by GetDriverPath(). On output, a pointer to the next driver
+ device path.
@retval EFI_UNSUPPORTED
**/
EFI_STATUS
EFIAPI
GetDriverPath (
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
+ IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath
)
@@ -167,30 +123,89 @@ GetDriverPath (
/**
- For the use of the ControllerHandle parameter in the DriverLoaded()
- But this API is very difficult to use, so not support.
-
- @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 DriverImagePath The device path for this Image.
- @param DriverImageHandle On input, a pointer to the previous driver image
- handle returned by GetDriver(). On output, a
- pointer to the next driver image handle. Passing
- in a NULL, will return the first driver image
- handle for ControllerHandle.
+ Used to associate a driver image handle with a device path that was returned on a prior call to the
+ GetDriverPath() service. This driver image handle will then be available through the
+ GetDriver() service. This driver doesn't support this API.
+
+ @param This A pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_
+ PROTOCOL instance.
+ @param ControllerHandle The device handle of the controller.
+ @param DriverImagePath A pointer to the driver device path that was returned in a prior
+ call to GetDriverPath().
+ @param DriverImageHandle The driver image handle that was returned by LoadImage()
+ when the driver specified by DriverImagePath was loaded
+ into memory.
@retval EFI_UNSUPPORTED
**/
EFI_STATUS
EFIAPI
DriverLoaded (
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
+ IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * DriverImagePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *DriverImagePath,
IN EFI_HANDLE DriverImageHandle
)
{
return EFI_UNSUPPORTED;
}
+
+EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL mPlatformDriverOverride = {
+ GetDriver,
+ GetDriverPath,
+ DriverLoaded
+};
+
+/**
+ Platform Driver Override driver entry point, install the Platform Driver Override Protocol
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The DXE Driver, DXE Runtime Driver, DXE SMM Driver,
+ or UEFI Driver exited normally.
+ @retval EFI_ALREADY_STARTED A protocol instance has been installed. Not need install again.
+**/
+EFI_STATUS
+EFIAPI
+PlatformDriverOverrideEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ VOID *Instance;
+
+ mCallerImageHandle = ImageHandle;
+
+ //
+ // 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->LocateProtocol (
+ &gEfiPlatformDriverOverrideProtocolGuid,
+ NULL,
+ &Instance
+ );
+ //
+ // If there was no error, assume there is an installation and return error
+ //
+ if (!EFI_ERROR (Status)) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ //
+ // Install platform driver override protocol
+ //
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gEfiPlatformDriverOverrideProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mPlatformDriverOverride
+ );
+ ASSERT_EFI_ERROR (Status);
+ return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.h b/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.h
deleted file mode 100644
index 31f2077..0000000
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file
-
-Copyright (c) 2007, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
- PlatformDriOverride.h
-
-Abstract:
-
-
-**/
-
-#ifndef _PLATFORM_DRI_OVERRIDE_H_
-#define _PLATFORM_DRI_OVERRIDE_H_
-
-#include <Uefi.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/PlatDriOverLib.h>
-
-/**
- Retrieves the image handle of the platform override driver for a controller in the system.
-
- @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, a pointer to the previous driver image
- handle returned by GetDriver(). On output, a
- pointer to the next driver image handle. Passing
- in a NULL, will return the first driver image
- handle for ControllerHandle.
-
- @retval EFI_SUCCESS The driver override for ControllerHandle was
- returned in DriverImageHandle.
- @retval EFI_NOT_FOUND A driver override for ControllerHandle was not
- found.
- @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not a
- valid handle. DriverImageHandle is not a handle
- that was returned on a previous call to
- GetDriver().
-
-**/
-EFI_STATUS
-EFIAPI
-GetDriver (
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
- IN EFI_HANDLE ControllerHandle,
- IN OUT EFI_HANDLE * DriverImageHandle
- );
-
-/**
- For the use of the ControllerHandle parameter in the GetDriverPath()
- But this API is very difficult to use, so not support.
-
- @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 DriverImagePath The device path for this Image.
-
- @retval EFI_UNSUPPORTED
-**/
-EFI_STATUS
-EFIAPI
-GetDriverPath (
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
- IN EFI_HANDLE ControllerHandle,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath
- );
-
-/**
- For the use of the ControllerHandle parameter in the DriverLoaded()
- But this API is very difficult to use, so not support.
-
- @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 DriverImagePath The device path for this Image.
- @param DriverImageHandle On input, a pointer to the previous driver image
- handle returned by GetDriver(). On output, a
- pointer to the next driver image handle. Passing
- in a NULL, will return the first driver image
- handle for ControllerHandle.
-
- @retval EFI_UNSUPPORTED
-**/
-EFI_STATUS
-EFIAPI
-DriverLoaded (
- IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * DriverImagePath,
- IN EFI_HANDLE DriverImageHandle
- );
-#endif
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf b/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf
index c5f45e1..299e42c 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf
@@ -1,8 +1,10 @@
#/** @file
-# Component name for module PlatformDriOverride
-#
-# FIX ME!
-# Copyright (c) 2007, Intel Corporation. All rights reserved.
+# This driver produces UEFI PLATFORM_DRIVER_OVERRIDE_PROTOCOL if this protocol doesn't exist.
+# It doesn't install again if this protocol exists.
+# It only implements one interface GetDriver of PLATFORM_DRIVER_OVERRIDE_PROTOCOL protocol
+# and doesn't support other two interfaces GetDriverPath, DriverLoaded.
+#
+# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -12,14 +14,13 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PlatformDriOverrideDxe
FILE_GUID = 35034CE2-A6E5-4fb4-BABE-A0156E9B2549
- MODULE_TYPE = DXE_DRIVER
+ MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = PlatformDriverOverrideEntry
@@ -31,7 +32,6 @@
[Sources.common]
PlatformDriOverride.c
- PlatformDriOverride.h
[Packages]
MdePkg/MdePkg.dec
@@ -42,4 +42,8 @@
UefiDriverEntryPoint
DebugLib
PlatDriOverLib
+ UefiBootServicesTableLib
+[Protocols]
+ gEfiPlatformDriverOverrideProtocolGuid # ALWAYS_PRODUCED
+ \ No newline at end of file