3 This library provides basic platform driver override functions.
5 Copyright (c) 2007 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _PLAT_DRI_OVER_LIB_H_
17 #define _PLAT_DRI_OVER_LIB_H_
19 #include <Protocol/PlatformDriverOverride.h>
20 #include <Protocol/DevicePath.h>
21 #include <Protocol/DriverBinding.h>
22 #include <Library/BaseLib.h>
24 #include <VariableFormat.h>
27 Install the Platform Driver Override Protocol, and ensure there is only one Platform Driver Override Protocol
30 @param gPlatformDriverOverride PlatformDriverOverride protocol interface which
33 @retval EFI_ALREADY_STARTED There has been a Platform Driver Override
34 Protocol in the system, cannot install it again.
35 @retval EFI_SUCCESS The protocol is installed successfully.
40 InstallPlatformDriverOverrideProtocol (
41 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
*gPlatformDriverOverride
45 Free all the mapping database memory resource and initialize the mapping list entry.
47 @param MappingDataBase Mapping database list entry pointer
49 @retval EFI_INVALID_PARAMETER mapping database list entry is NULL
50 @retval EFI_SUCCESS Free success
56 IN OUT LIST_ENTRY
*MappingDataBase
60 Read the environment variable(s) that contain the override mappings from Controller Device Path to
61 a set of Driver Device Paths, and create the mapping database in memory with those variable info.
63 @param MappingDataBase Mapping database list entry pointer
65 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
66 @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable
67 @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted
68 @retval EFI_SUCCESS Create the mapping database in memory successfully
73 InitOverridesMapping (
74 OUT LIST_ENTRY
*MappingDataBase
78 Save the memory mapping database into NV environment variable(s).
80 @param MappingDataBase Mapping database list entry pointer
82 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
83 @retval EFI_SUCCESS Save memory mapping database successfully
88 SaveOverridesMapping (
89 IN LIST_ENTRY
*MappingDataBase
93 Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.
95 @param This A pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.
96 @param ControllerHandle The device handle of the controller to check if
97 a driver override exists.
98 @param DriverImageHandle On output, a pointer to the next driver handle.
99 Passing in a pointer to NULL, will return the
100 first driver handle for ControllerHandle.
101 @param MappingDataBase MappingDataBase - Mapping database list entry
103 @param CallerImageHandle The caller driver's image handle, for
104 UpdateFvFileDevicePath use.
106 @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not
107 a valid handle. Or DriverImagePath is not a
108 device path that was returned on a previous call
110 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not
112 @retval EFI_UNSUPPORTED The operation is not supported.
113 @retval EFI_SUCCESS The driver override for ControllerHandle was
114 returned in DriverImagePath.
119 GetDriverFromMapping (
120 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
121 IN EFI_HANDLE ControllerHandle
,
122 IN OUT EFI_HANDLE
* DriverImageHandle
,
123 IN LIST_ENTRY
* MappingDataBase
,
124 IN EFI_HANDLE CallerImageHandle
128 Deletes all environment variable(s) that contain the override mappings from Controller Device Path to
129 a set of Driver Device Paths.
131 @retval EFI_SUCCESS Delete all variable(s) successfully.
135 DeleteOverridesVariables (
140 Check mapping database whether already has the mapping info which
141 records the input Controller to input DriverImage.
143 @param ControllerDevicePath The controller device path is to be check.
144 @param DriverImageDevicePath The driver image device path is to be check.
145 @param MappingDataBase Mapping database list entry pointer
146 @param DriverInfoNum the controller's total override driver number
147 @param DriverImageNO The driver order number for the input DriverImage.
148 If the DriverImageDevicePath is NULL, DriverImageNO is not set.
150 @retval EFI_INVALID_PARAMETER ControllerDevicePath or MappingDataBase is NULL.
151 @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or
152 DriverImageDevicePath is not found in the found DriverImage Info list.
153 @retval EFI_SUCCESS The controller's total override driver number and
154 input DriverImage's order number is correctly return.
159 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
160 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath OPTIONAL
,
161 IN LIST_ENTRY
*MappingDataBase
,
162 OUT UINT32
*DriverInfoNum OPTIONAL
,
163 OUT UINT32
*DriverImageNO OPTIONAL
167 Insert a driver image as a controller's override driver into the mapping database.
168 The driver image's order number is indicated by DriverImageNO.
170 @param ControllerDevicePath The controller device path need to add a
171 override driver image item
172 @param DriverImageDevicePath The driver image device path need to be insert
173 @param MappingDataBase Mapping database list entry pointer
174 @param DriverImageNO The inserted order number. If this number is taken,
175 the larger available number will be used.
177 @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or DriverImageDevicePath is NULL
178 or MappingDataBase is NULL
179 @retval EFI_ALREADY_STARTED The input Controller to input DriverImage has been
180 recorded into the mapping database.
181 @retval EFI_SUCCESS The Controller and DriverImage are inserted into
182 the mapping database successfully.
188 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
189 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
190 IN LIST_ENTRY
*MappingDataBase
,
191 IN UINT32 DriverImageNO
195 Delete a controller's override driver from the mapping database.
197 @param ControllerDevicePath The controller device path will be deleted
198 when all drivers images on it are removed.
199 @param DriverImageDevicePath The driver image device path will be delete.
200 If NULL, all driver image will be delete.
201 @param MappingDataBase Mapping database list entry pointer
203 @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or MappingDataBase is NULL
204 @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or
205 DriverImageDevicePath is not found in the found DriverImage Info list.
206 @retval EFI_SUCCESS Delete the specified driver successfully.
212 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
213 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
214 IN LIST_ENTRY
*MappingDataBase
218 Get the first Binding protocol which has the specific image handle
220 @param ImageHandle The Image handle
221 @param BindingHandle The BindingHandle of the found Driver Binding protocol.
222 If Binding protocol is not found, it is set to NULL.
224 @return Pointer into the Binding Protocol interface
225 @retval NULL The paramter is not valid or the binding protocol is not found.
228 EFI_DRIVER_BINDING_PROTOCOL
*
230 GetBindingProtocolFromImageHandle (
231 IN EFI_HANDLE ImageHandle
,
232 OUT EFI_HANDLE
*BindingHandle