TianoCore EDK2 master
Loading...
Searching...
No Matches
PlatDriOverrideDxe.c File Reference

Go to the source code of this file.

Data Structures

struct  EFI_CALLBACK_INFO
 
struct  HII_VENDOR_DEVICE_PATH
 

Macros

#define EFI_CALLBACK_INFO_SIGNATURE   SIGNATURE_32 ('C', 'l', 'b', 'k')
 
#define EFI_CALLBACK_INFO_FROM_THIS(a)   CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)
 

Functions

CHAR16 * DevicePathToStr (IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
 
CHAR16 * GetComponentNameWorker (IN EFI_HANDLE DriverBindingHandle, IN EFI_GUID *ProtocolGuid, IN CONST CHAR16 *VariableName)
 
CHAR16 * GetComponentName (IN EFI_HANDLE DriverBindingHandle)
 
CHAR16 * GetImageName (IN EFI_LOADED_IMAGE_PROTOCOL *Image)
 
EFI_STATUS UpdateDeviceSelectPage (IN EFI_CALLBACK_INFO *Private, IN UINT16 KeyValue, IN PLAT_OVER_MNGR_DATA *FakeNvData)
 
EFI_HANDLE GetDriverBindingHandleFromImageHandle (IN EFI_HANDLE ImageHandle)
 
EFI_STATUS UpdateBindingDriverSelectPage (IN EFI_CALLBACK_INFO *Private, IN UINT16 KeyValue, IN PLAT_OVER_MNGR_DATA *FakeNvData)
 
EFI_STATUS UpdatePrioritySelectPage (IN EFI_CALLBACK_INFO *Private, IN UINT16 KeyValue, IN PLAT_OVER_MNGR_DATA *FakeNvData)
 
EFI_STATUS CommitChanges (IN EFI_CALLBACK_INFO *Private, IN UINT16 KeyValue, IN PLAT_OVER_MNGR_DATA *FakeNvData)
 
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)
 
EFI_STATUS EFIAPI GetDriver (IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN OUT EFI_HANDLE *DriverImageHandle)
 
EFI_STATUS EFIAPI GetDriverPath (IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath)
 
EFI_STATUS EFIAPI DriverLoaded (IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *DriverImagePath, IN EFI_HANDLE DriverImageHandle)
 
EFI_STATUS EFIAPI PlatDriOverrideDxeInit (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI PlatDriOverrideDxeUnload (IN EFI_HANDLE ImageHandle)
 

Variables

UINT8 VfrBin []
 
UINT8 PlatDriOverrideDxeStrings []
 
CHAR16 mVariableName [] = L"Data"
 
LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase)
 
BOOLEAN mEnvironmentVariableRead = FALSE
 
EFI_HANDLE mCallerImageHandle = NULL
 
EFI_HANDLEmDevicePathHandleBuffer
 
EFI_HANDLEmDriverImageHandleBuffer
 
INTN mSelectedCtrIndex
 
EFI_STRING_ID * mControllerToken
 
UINTN mDriverImageHandleCount
 
EFI_STRING_ID * mDriverImageToken
 
EFI_DEVICE_PATH_PROTOCOL ** mControllerDevicePathProtocol
 
UINTN mSelectedDriverImageNum
 
UINTN mLastSavedDriverImageNum
 
UINT16 mCurrentPage
 
EFI_CALLBACK_INFOmCallbackInfo
 
BOOLEAN * mDriSelection
 
UINTN mMaxDeviceCount
 
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath
 

Detailed Description

This file also installs UEFI PLATFORM_DRIVER_OVERRIDE_PROTOCOL.

The main code offers a UI interface in device manager to let user configure platform override protocol to override the default algorithm for matching drivers to controllers.

The main flow:

  1. It dynamicly locate all controller device path.
  2. It dynamicly locate all drivers which support binding protocol.
  3. It export and dynamicly update two menu to let user select the mapping between drivers to controllers.
  4. It save all the mapping info in NV variables which will be consumed by platform override protocol driver to publish the platform override protocol.

Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PlatDriOverrideDxe.c.

Macro Definition Documentation

◆ EFI_CALLBACK_INFO_FROM_THIS

#define EFI_CALLBACK_INFO_FROM_THIS (   a)    CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)

Definition at line 25 of file PlatDriOverrideDxe.c.

◆ EFI_CALLBACK_INFO_SIGNATURE

#define EFI_CALLBACK_INFO_SIGNATURE   SIGNATURE_32 ('C', 'l', 'b', 'k')

Definition at line 24 of file PlatDriOverrideDxe.c.

Function Documentation

◆ CommitChanges()

EFI_STATUS CommitChanges ( IN EFI_CALLBACK_INFO Private,
IN UINT16  KeyValue,
IN PLAT_OVER_MNGR_DATA FakeNvData 
)

Save the save the mapping database to NV variable.

Parameters
PrivatePointer to EFI_CALLBACK_INFO.
KeyValueThe callback key value of device controller item in first page.
FakeNvDataPointer to PLAT_OVER_MNGR_DATA.
Return values
EFI_SUCCESSAlways returned.

Definition at line 1114 of file PlatDriOverrideDxe.c.

◆ DevicePathToStr()

CHAR16 * DevicePathToStr ( IN EFI_DEVICE_PATH_PROTOCOL DevPath)

Converting a given device to an unicode string.

Parameters
DevPathGiven device path instance
Returns
Converted string from given device path.
Return values
L"?"Converting failed.

Definition at line 109 of file PlatDriOverrideDxe.c.

◆ DriverLoaded()

EFI_STATUS EFIAPI DriverLoaded ( IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL DriverImagePath,
IN EFI_HANDLE  DriverImageHandle 
)

Used to associate a driver image handle with a device path that was returned on a prior call to the GetDriverPath() service. This driver image handle will then be available through the GetDriver() service. This driver doesn't support this API.

Parameters
ThisA pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_ PROTOCOL instance.
ControllerHandleThe device handle of the controller.
DriverImagePathA pointer to the driver device path that was returned in a prior call to GetDriverPath().
DriverImageHandleThe driver image handle that was returned by LoadImage() when the driver specified by DriverImagePath was loaded into memory.
Return values
EFI_UNSUPPORTED

Definition at line 1580 of file PlatDriOverrideDxe.c.

◆ GetComponentName()

CHAR16 * GetComponentName ( IN EFI_HANDLE  DriverBindingHandle)

Get the driver name by ComponentName or ComponentName2 protocol according to the driver binding handle

Parameters
DriverBindingHandleThe Handle of DriverBinding.
Return values
!NULLPointer into the image name if the image name is found,
NULLPointer to NULL if the image name is not found.

Definition at line 204 of file PlatDriOverrideDxe.c.

◆ GetComponentNameWorker()

CHAR16 * GetComponentNameWorker ( IN EFI_HANDLE  DriverBindingHandle,
IN EFI_GUID ProtocolGuid,
IN CONST CHAR16 *  VariableName 
)

Worker function to get the driver name by ComponentName or ComponentName2 protocol according to the driver binding handle.

Parameters
DriverBindingHandleThe Handle of DriverBinding.
ProtocolGuidThe pointer to Component Name (2) protocol GUID.
VariableNameThe name of the RFC 4646 or ISO 639-2 language variable.
Return values
!NULLPointer into the image name if the image name is found,
NULLPointer to NULL if the image name is not found.

Definition at line 141 of file PlatDriOverrideDxe.c.

◆ GetDriver()

EFI_STATUS EFIAPI GetDriver ( IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN OUT EFI_HANDLE DriverImageHandle 
)

Retrieves the image handle of the platform override driver for a controller in the system.

Parameters
ThisA pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.
ControllerHandleThe device handle of the controller to check if a driver override exists.
DriverImageHandleOn input, a pointer to the previous driver image handle returned by GetDriver(). On output, a pointer to the next driver image handle. Passing in a NULL, will return the first driver image handle for ControllerHandle.
Return values
EFI_SUCCESSThe driver override for ControllerHandle was returned in DriverImageHandle.
EFI_NOT_FOUNDA driver override for ControllerHandle was not found.
EFI_INVALID_PARAMETERThe handle specified by ControllerHandle is NULL. DriverImageHandle is not a handle that was returned on a previous call to GetDriver().

Definition at line 1489 of file PlatDriOverrideDxe.c.

◆ GetDriverBindingHandleFromImageHandle()

EFI_HANDLE GetDriverBindingHandleFromImageHandle ( IN EFI_HANDLE  ImageHandle)

Get the first Driver Binding handle which has the specific image handle.

Parameters
ImageHandleThe Image handle
Returns
Handle to Driver binding
Return values
NULLThe parameter is not valid or the driver binding handle is not found.

Definition at line 548 of file PlatDriOverrideDxe.c.

◆ GetDriverPath()

EFI_STATUS EFIAPI GetDriverPath ( IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN OUT EFI_DEVICE_PATH_PROTOCOL **  DriverImagePath 
)

Retrieves the device path of the platform override driver for a controller in the system. This driver doesn't support this API.

Parameters
ThisA pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_ PROTOCOL instance.
ControllerHandleThe device handle of the controller to check if a driver override exists.
DriverImagePathOn input, a pointer to the previous driver device path returned by GetDriverPath(). On output, a pointer to the next driver device path. Passing in a pointer to NULL, will return the first driver device path for ControllerHandle.
Return values
EFI_UNSUPPORTED

Definition at line 1553 of file PlatDriOverrideDxe.c.

◆ GetImageName()

CHAR16 * GetImageName ( IN EFI_LOADED_IMAGE_PROTOCOL Image)

Get the image name from EFI UI section. Get FV protocol by its loaded image protocol to abstract EFI UI section.

Parameters
ImagePointer to the loaded image protocol
Return values
!NULLPointer to the image name if the image name is found,
NULLNULL if the image name is not found.

Definition at line 235 of file PlatDriOverrideDxe.c.

◆ PlatDriOverrideDxeInit()

EFI_STATUS EFIAPI PlatDriOverrideDxeInit ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The driver Entry Point. The function will export a disk device class formset and its callback function to hii database.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
otherSome error occurs when executing this entry point.

Definition at line 1603 of file PlatDriOverrideDxe.c.

◆ PlatDriOverrideDxeUnload()

EFI_STATUS EFIAPI PlatDriOverrideDxeUnload ( IN EFI_HANDLE  ImageHandle)

Unload its installed protocol.

Parameters
[in]ImageHandleHandle that identifies the image to be unloaded.
Return values
EFI_SUCCESSThe image has been unloaded.

Definition at line 1723 of file PlatDriOverrideDxe.c.

◆ PlatOverMngrCallback()

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 
)

This is the function that is called to provide results data to the driver. This data consists of a unique key which is used to identify what data is either being passed back or being asked for.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ActionA null-terminated Unicode string in <ConfigRequest> format.
KeyValueA unique Goto OpCode callback value which record user's selection. 0x100 <= KeyValue <0x500 : user select a controller item in the first page; KeyValue == 0x1234 : user select 'Refresh' in first page, or user select 'Go to Previous Menu' in second page KeyValue == 0x1235 : user select 'Pci device filter' in first page KeyValue == 0x1500 : user select 'order ... priority' item in second page KeyValue == 0x1800 : user select 'commint changes' in third page KeyValue == 0x2000 : user select 'Go to Previous Menu' in third page
TypeThe type of value for the question.
ValueA pointer to the data being sent to the original exporting driver.
ActionRequestOn return, points to the action requested by the callback function.
Return values
EFI_SUCCESSAlways returned.

Definition at line 1345 of file PlatDriOverrideDxe.c.

◆ PlatOverMngrExtractConfig()

EFI_STATUS EFIAPI PlatOverMngrExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Request,
OUT EFI_STRING *  Progress,
OUT EFI_STRING *  Results 
)

This function allows a caller to extract the current configuration for one or more named elements from the target driver.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
RequestA null-terminated Unicode string in <ConfigRequest> format.
ProgressOn return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) if the request was not successful.
ResultsA null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function.
Return values
EFI_SUCCESSThe Results is filled with the requested values.
EFI_OUT_OF_RESOURCESNot enough memory to store the results.
EFI_INVALID_PARAMETERRequest is illegal syntax, or unknown name.
EFI_NOT_FOUNDRouting data doesn't match any storage in this driver.

Definition at line 1183 of file PlatDriOverrideDxe.c.

◆ PlatOverMngrRouteConfig()

EFI_STATUS EFIAPI PlatOverMngrRouteConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Configuration,
OUT EFI_STRING *  Progress 
)

This function processes the results of changes in configuration.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ConfigurationA null-terminated Unicode string in <ConfigRequest> format.
ProgressA pointer to a string filled in with the offset of the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) or the terminating NULL if all was successful.
Return values
EFI_SUCCESSThe Results is processed successfully.
EFI_INVALID_PARAMETERConfiguration is NULL.
EFI_NOT_FOUNDRouting data doesn't match any storage in this driver.

Definition at line 1281 of file PlatDriOverrideDxe.c.

◆ UpdateBindingDriverSelectPage()

EFI_STATUS UpdateBindingDriverSelectPage ( IN EFI_CALLBACK_INFO Private,
IN UINT16  KeyValue,
IN PLAT_OVER_MNGR_DATA FakeNvData 
)

Prepare to let user select the drivers which need mapping with the device controller selected in first page.

Parameters
PrivatePointer to EFI_CALLBACK_INFO.
KeyValueThe callback key value of device controller item in first page. KeyValue is larger than or equal to KEY_VALUE_DEVICE_OFFSET.
FakeNvDataPointer to PLAT_OVER_MNGR_DATA.
Return values
EFI_SUCCESSAlways returned.

Definition at line 620 of file PlatDriOverrideDxe.c.

◆ UpdateDeviceSelectPage()

EFI_STATUS UpdateDeviceSelectPage ( IN EFI_CALLBACK_INFO Private,
IN UINT16  KeyValue,
IN PLAT_OVER_MNGR_DATA FakeNvData 
)

Prepare the first page to let user select the device controller which need to add mapping drivers if user select 'Refresh' in first page. During first page, user will see all currnet controller device path in system, select any device path will go to second page to select its overrides drivers.

Parameters
PrivatePointer to EFI_CALLBACK_INFO.
KeyValueThe callback key value of device controller item in first page.
FakeNvDataPointer to PLAT_OVER_MNGR_DATA.
Return values
EFI_SUCCESSAlways returned.

Definition at line 323 of file PlatDriOverrideDxe.c.

◆ UpdatePrioritySelectPage()

EFI_STATUS UpdatePrioritySelectPage ( IN EFI_CALLBACK_INFO Private,
IN UINT16  KeyValue,
IN PLAT_OVER_MNGR_DATA FakeNvData 
)

Prepare to let user select the priority order of the drivers which are selected in second page.

Parameters
PrivatePointer to EFI_CALLBACK_INFO.
KeyValueThe callback key value of device controller item in first page.
FakeNvDataPointer to PLAT_OVER_MNGR_DATA.
Return values
EFI_SUCCESSAlways returned.

Definition at line 911 of file PlatDriOverrideDxe.c.

Variable Documentation

◆ mCallbackInfo

EFI_CALLBACK_INFO* mCallbackInfo

Definition at line 74 of file PlatDriOverrideDxe.c.

◆ mCallerImageHandle

EFI_HANDLE mCallerImageHandle = NULL

Definition at line 61 of file PlatDriOverrideDxe.c.

◆ mControllerDevicePathProtocol

EFI_DEVICE_PATH_PROTOCOL** mControllerDevicePathProtocol

Definition at line 70 of file PlatDriOverrideDxe.c.

◆ mControllerToken

EFI_STRING_ID* mControllerToken

Definition at line 67 of file PlatDriOverrideDxe.c.

◆ mCurrentPage

UINT16 mCurrentPage

Definition at line 73 of file PlatDriOverrideDxe.c.

◆ mDevicePathHandleBuffer

EFI_HANDLE* mDevicePathHandleBuffer

Definition at line 63 of file PlatDriOverrideDxe.c.

◆ mDriSelection

BOOLEAN* mDriSelection

Definition at line 75 of file PlatDriOverrideDxe.c.

◆ mDriverImageHandleBuffer

EFI_HANDLE* mDriverImageHandleBuffer

Definition at line 64 of file PlatDriOverrideDxe.c.

◆ mDriverImageHandleCount

UINTN mDriverImageHandleCount

Definition at line 68 of file PlatDriOverrideDxe.c.

◆ mDriverImageToken

EFI_STRING_ID* mDriverImageToken

Definition at line 69 of file PlatDriOverrideDxe.c.

◆ mEnvironmentVariableRead

BOOLEAN mEnvironmentVariableRead = FALSE

Definition at line 60 of file PlatDriOverrideDxe.c.

◆ mHiiVendorDevicePath

HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath
Initial value:
= {
{
{
{
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
PLAT_OVER_MNGR_GUID
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
}
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133

Definition at line 78 of file PlatDriOverrideDxe.c.

◆ mLastSavedDriverImageNum

UINTN mLastSavedDriverImageNum

Definition at line 72 of file PlatDriOverrideDxe.c.

◆ mMappingDataBase

LIST_ENTRY mMappingDataBase = INITIALIZE_LIST_HEAD_VARIABLE (mMappingDataBase)

Definition at line 59 of file PlatDriOverrideDxe.c.

◆ mMaxDeviceCount

UINTN mMaxDeviceCount

Definition at line 76 of file PlatDriOverrideDxe.c.

◆ mSelectedCtrIndex

INTN mSelectedCtrIndex

Definition at line 66 of file PlatDriOverrideDxe.c.

◆ mSelectedDriverImageNum

UINTN mSelectedDriverImageNum

Definition at line 71 of file PlatDriOverrideDxe.c.

◆ mVariableName

CHAR16 mVariableName[] = L"Data"

Definition at line 58 of file PlatDriOverrideDxe.c.