3 Copyright (c) 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #ifndef _PLAT_DRI_OVER_LIB_H_
22 #define _PLAT_DRI_OVER_LIB_H_
25 #include <Protocol/PlatformDriverOverride.h>
26 #include <Protocol/DevicePath.h>
27 #include <Library/BaseLib.h>
29 #include <VariableFormat.h>
32 Install the Platform Driver Override Protocol, and ensure there is only one Platform Driver Override Protocol
35 @param gPlatformDriverOverride PlatformDriverOverride protocol interface which
38 @retval EFI_ALREADY_STARTED There has been a Platform Driver Override
39 Protocol in the system, cannot install it again.
40 @retval Other Returned by InstallProtocolInterface
45 InstallPlatformDriverOverrideProtocol (
46 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
*gPlatformDriverOverride
50 Free all the mapping database memory resource and initialize the mapping list entry
52 @param MappingDataBase Mapping database list entry pointer
54 @retval EFI_INVALID_PARAMETER mapping database list entry is NULL
55 @retval EFI_SUCCESS Free success
61 IN OUT LIST_ENTRY
*MappingDataBase
65 Read the environment variable(s) that contain the override mappings from Controller Device Path to
66 a set of Driver Device Paths, and create the mapping database in memory with those variable info.
69 // NotEnd indicate whether the variable is the last one, and has no subsequent variable need to load.
70 // Each variable has MaximumVariableSize limitation, so we maybe need multi variables to store
71 // large mapping infos.
72 // The variable(s) name rule is PlatDriOver, PlatDriOver1, PlatDriOver2, ....
76 // The entry which contains the mapping that Controller Device Path to a set of Driver Device Paths
77 // There are often multi mapping entries in a variable.
79 UINT32 SIGNATURE; //EFI_SIGNATURE_32('p','d','o','i')
81 EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];
82 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
83 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
84 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
88 EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];
89 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
90 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
91 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];
94 typedef struct _PLATFORM_OVERRIDE_ITEM{
95 UINTN Signature; //EFI_SIGNATURE_32('p','d','o','i')
98 EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;
99 LIST_ENTRY DriverInfoList; //DRIVER_IMAGE_INFO List
100 } PLATFORM_OVERRIDE_ITEM;
101 typedef struct _DRIVER_IMAGE_INFO{
102 UINTN Signature; //EFI_SIGNATURE_32('p','d','i','i')
104 EFI_HANDLE ImageHandle;
105 EFI_DEVICE_PATH_PROTOCOL *DriverImagePath;
110 @param MappingDataBase Mapping database list entry pointer
112 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
113 @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable
114 @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted
115 @retval EFI_SUCCESS Create the mapping database in memory
121 InitOverridesMapping (
122 OUT LIST_ENTRY
*MappingDataBase
126 Save the memory mapping database into NV environment variable(s)
128 @param MappingDataBase Mapping database list entry pointer
130 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
131 @retval EFI_SUCCESS Save memory mapping database successfully
136 SaveOverridesMapping (
137 IN LIST_ENTRY
*MappingDataBase
141 Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.
143 @param This A pointer to the
144 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.
145 @param ControllerHandle The device handle of the controller to check if
146 a driver override exists.
147 @param DriverImageHandle On output, a pointer to the next driver handle.
148 Passing in a pointer to NULL, will return the
149 first driver handle for ControllerHandle.
150 @param MappingDataBase MappingDataBase - Mapping database list entry
152 @param CallerImageHandle The caller driver's image handle, for
153 UpdateFvFileDevicePath use.
155 @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not
156 a valid handle. Or DriverImagePath is not a
157 device path that was returned on a previous call
159 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not
161 @retval EFI_UNSUPPORTED The operation is not supported.
162 @retval EFI_SUCCESS The driver override for ControllerHandle was
163 returned in DriverImagePath.
168 GetDriverFromMapping (
169 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL
* This
,
170 IN EFI_HANDLE ControllerHandle
,
171 IN OUT EFI_HANDLE
* DriverImageHandle
,
172 IN LIST_ENTRY
* MappingDataBase
,
173 IN EFI_HANDLE CallerImageHandle
178 DeleteOverridesVariables (
183 Check mapping database whether already has the mapping info which
184 records the input Controller to input DriverImage.
185 If has, the controller's total override driver number and input DriverImage's order number is return.
187 @param ControllerDevicePath The controller device path need to add a
188 override driver image item
189 @param DriverImageDevicePath The driver image device path need to be insert
190 @param MappingDataBase Mapping database list entry pointer
191 @param DriverInfoNum the controller's total override driver number
192 @param DriverImageNO The inserted order number
194 @return EFI_INVALID_PARAMETER
195 @return EFI_NOT_FOUND
202 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
203 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
204 IN LIST_ENTRY
* MappingDataBase
,
205 OUT UINT32
*DriverInfoNum
,
206 OUT UINT32
*DriverImageNO
210 Insert a driver image as a controller's override driver into the mapping database.
211 The driver image's order number is indicated by DriverImageNO.
213 @param ControllerDevicePath The controller device path need to add a
214 override driver image item
215 @param DriverImageDevicePath The driver image device path need to be insert
216 @param MappingDataBase Mapping database list entry pointer
217 @param DriverImageNO The inserted order number
219 @return EFI_INVALID_PARAMETER
220 @return EFI_ALREADY_STARTED
227 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
228 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
229 IN LIST_ENTRY
*MappingDataBase
,
230 IN UINT32 DriverImageNO
234 Delete a controller's override driver from the mapping database.
236 @param ControllerDevicePath The controller device path need to add a
237 override driver image item
238 @param DriverImageDevicePath The driver image device path need to be insert
239 @param MappingDataBase Mapping database list entry pointer
240 @param DriverImageNO The inserted order number
242 @return EFI_INVALID_PARAMETER
243 @return EFI_NOT_FOUND
250 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
251 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
252 IN LIST_ENTRY
*MappingDataBase