1.Port Platform driver override protocol utility application in MdeModulePkg.dsc.

2.Update PlatDriOverLib library to use EFI Loaded Image Device Path Protocol to avoid "reconnect -r" issue for Platform driver override utility application.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5006 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2008-04-08 09:34:21 +00:00
parent c4fa3eacb3
commit 23d64dda6b
8 changed files with 1839 additions and 28 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,184 @@
/** @file
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
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 <Uefi.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 EFI_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;
#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
//
// Question Id start from 1, so define an offset for it
//
#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))
#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;
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
);
EFI_STATUS
EFIAPI
PlatOverMngrRouteConfig (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Configuration,
OUT EFI_STRING *Progress
);
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
);
CHAR16 *
GetImageName (
IN EFI_LOADED_IMAGE_PROTOCOL *Image
);
CHAR16 *
DevicePathToStr (
EFI_DEVICE_PATH_PROTOCOL *DevPath
);
EFI_DEVICE_PATH_PROTOCOL *
UnpackDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *DevPath
);
#endif

View File

@ -0,0 +1,74 @@
#/** @file
# Component description file for PlatOverMngr driver
#
# FIX ME!
# 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
# 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.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PlatOverMngr
FILE_GUID = 56D95BFE-F991-4898-B3BE-B8F37C927F48
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = PlatOverMngrInit
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
VfrStrings.uni
Vfr.vfr
PlatOverMngr.c
PlatOverMngr.h
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
BaseLib
UefiBootServicesTableLib
UefiApplicationEntryPoint
UefiLib
DebugLib
PlatDriOverLib
IfrSupportLib
ExtendedIfrSupportLib
BaseMemoryLib
MemoryAllocationLib
HiiLib
ExtendedHiiLib
UefiRuntimeServicesTableLib
DevicePathLib
[Protocols]
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
# gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiHiiConfigAccessProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDevicePathToTextProtocolGuid # PROTOCOL ALWAYS_CONSUMED
[Depex]
gEfiHiiDatabaseProtocolGuid

View File

@ -0,0 +1,141 @@
// *++
//
// 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:
//
// Vfr.vfr
//
// Abstract:
//
// Platform driver Override manager formset
//
//
// --*/
#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
#define EFI_DISK_DEVICE_CLASS 0x01
#define LABEL_END 0xffff
formset
guid = PLAT_OVER_MNGR_GUID,
title = STRING_TOKEN(STR_ENTRY_TITLE),
help = STRING_TOKEN(STR_TITLE_HELP),
class = EFI_DISK_DEVICE_CLASS,
subclass = 0xff,
varstore PLAT_OVER_MNGR_DATA,
varid = VARSTORE_ID_PLAT_OVER_MNGR,
name = Data,
guid = PLAT_OVER_MNGR_GUID;
form formid = FORM_ID_DEVICE,
title = STRING_TOKEN(STR_TITLE);
text
help = STRING_TOKEN(STR_FIRST_REFRESH_HELP),
text = STRING_TOKEN(STR_FIRST_REFRESH),
text = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE,
key = KEY_VALUE_DEVICE_REFRESH;
checkbox varid = Data.PciDeviceFilter,
prompt = STRING_TOKEN(STR_PCI_DEVICE_FILTER_PROMPT),
help = STRING_TOKEN(STR_PCI_DEVICE_FILTER_HELP),
flags = INTERACTIVE,
key = KEY_VALUE_DEVICE_FILTER,
endcheckbox;
label FORM_ID_DEVICE;
label LABEL_END;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FORM_ID_DEVICE,
prompt = STRING_TOKEN(STR_CLEAR_ALL),
help = STRING_TOKEN(STR_CLEAR_ALL_HELP),
flags = INTERACTIVE | RESET_REQUIRED,
key = KEY_VALUE_DEVICE_CLEAR;
endform;
form formid = FORM_ID_DRIVER,
title = STRING_TOKEN(STR_TITLE);
goto FORM_ID_DEVICE,
prompt = STRING_TOKEN(STR_GOTO_PREVIOUS),
help = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE,
key = KEY_VALUE_DRIVER_GOTO_PREVIOUS;
goto FORM_ID_ORDER,
prompt = STRING_TOKEN(STR_TITLE_ORDER),
help = STRING_TOKEN(STR_TITLE_ORDER_HELP),
flags = INTERACTIVE,
key = KEY_VALUE_DRIVER_GOTO_ORDER;
label FORM_ID_DRIVER;
label LABEL_END;
endform;
form formid = FORM_ID_ORDER,
title = STRING_TOKEN(STR_TITLE);
goto FORM_ID_DRIVER,
prompt = STRING_TOKEN(STR_GOTO_PREVIOUS),
help = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE,
key = KEY_VALUE_ORDER_GOTO_PREVIOUS;
label FORM_ID_ORDER;
label LABEL_END;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FORM_ID_ORDER,
prompt = STRING_TOKEN(STR_SAVE_AND_EXIT),
help = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE | RESET_REQUIRED,
key = KEY_VALUE_ORDER_SAVE_AND_EXIT;
endform;
endformset;

Binary file not shown.

View File

@ -62,4 +62,4 @@
gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDriverBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiLoadedImageDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED

View File

@ -666,7 +666,6 @@ GetDriverFromMapping (
EFI_HANDLE *ImageHandleBuffer;
UINTN ImageHandleCount;
UINTN Index;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_HANDLE DriverBindingHandle;
BOOLEAN FoundLastReturned;
@ -677,8 +676,7 @@ GetDriverFromMapping (
EFI_DEVICE_PATH_PROTOCOL *TempDriverImagePath;
EFI_HANDLE ImageHandle;
EFI_HANDLE Handle;
EFI_DEVICE_PATH_PROTOCOL *LoadedImageHandleDevicePath;
EFI_DEVICE_PATH_PROTOCOL *TatalFilePath;
EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;
UINTN DevicePathSize;
@ -786,39 +784,28 @@ GetDriverFromMapping (
}
for(Index = 0; Index < ImageHandleCount; Index ++) {
Status = gBS->HandleProtocol (
ImageHandleBuffer[Index],
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);
if (EFI_ERROR (Status)) {
continue;
}
//
// Get the driver image total file path
// Get the EFI Loaded Image Device Path Protocol
//
LoadedImageHandleDevicePath = NULL;
LoadedImageDevicePath = NULL;
Status = gBS->HandleProtocol (
LoadedImage->DeviceHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &LoadedImageHandleDevicePath
ImageHandleBuffer[Index],
&gEfiLoadedImageDevicePathProtocolGuid,
(VOID **) &LoadedImageDevicePath
);
if (EFI_ERROR (Status)) {
//
// Maybe Not all LoadedImage->DeviceHandle has valid value. Skip the invalid image.
// Maybe Not all EFI Loaded Image Device Path Protocol existed.
//
continue;
}
TatalFilePath = AppendDevicePath (LoadedImageHandleDevicePath, LoadedImage->FilePath);
DevicePathSize = GetDevicePathSize (DriverImageInfo->DriverImagePath);
if (DevicePathSize == GetDevicePathSize (TatalFilePath)) {
if (DevicePathSize == GetDevicePathSize (LoadedImageDevicePath)) {
if (CompareMem (
DriverImageInfo->DriverImagePath,
TatalFilePath,
GetDevicePathSize (TatalFilePath)
LoadedImageDevicePath,
GetDevicePathSize (LoadedImageDevicePath)
) == 0
) {
ImageFound = TRUE;
@ -1881,7 +1868,7 @@ ConnectDevicePath (
// change, so next time will do the dispatch, then dispatch's status
// will take effect
// 2. If the connect success, the RemainingDevicepath and handle will
// change, then avoid the dispatch, we have chance to continue the
// change, then avoid the dispatch, we have chance to continue the
// next connection
//
gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);

View File

@ -76,11 +76,11 @@
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
DxePiLib|MdePkg/Library/DxePiLib/DxePiLib.inf
PlatformBdsLib|MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf
GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
GraphicsLib|MdeModulePkg/Library/GraphicsLib/GraphicsLib.inf
DxePiLib|MdePkg/Library/DxePiLib/DxePiLib.inf
PlatformBdsLib|MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf
GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
PlatDriOverLib|MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf
OemHookStatusCodeLib|IntelFrameworkModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
@ -283,7 +283,7 @@
MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
@ -298,6 +298,7 @@
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf
MdeModulePkg/Application/PlatOverMngr/PlatOverMngr.inf
MdeModulePkg/Application/HelloWorld/HelloWorld.inf