]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code Clean for Driver PlatformDriOverrideDxe and PlatOverMngr application. And Clean...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 25 Dec 2008 09:13:53 +0000 (09:13 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 25 Dec 2008 09:13:53 +0000 (09:13 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7121 6f19259b-4bc3-4df7-8a09-765794883524

18 files changed:
MdeModulePkg/Include/Guid/AlternateFvBlock.h
MdeModulePkg/Include/Guid/OverrideVariable.h
MdeModulePkg/Include/Guid/SystemNvDataGuid.h
MdeModulePkg/Include/Library/PlatDriOverLib.h
MdeModulePkg/Include/Protocol/FaultTolerantWriteLite.h
MdeModulePkg/Include/VariableFormat.h
MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf
MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOver.h
MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
MdeModulePkg/Universal/PCD/Pei/Pcd.inf
MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf
MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/Vfr.vfr
MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.c
MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverride.h [deleted file]
MdeModulePkg/Universal/PlatformDriverOverride/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf

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