2 Ihe internal heder file includes the required Protocol/Guid/Library
3 and the shared function APIs.
5 Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>
6 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 _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_
17 #define _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_
21 #include <Protocol/HiiConfigAccess.h>
22 #include <Protocol/HiiConfigRouting.h>
23 #include <Protocol/HiiDatabase.h>
24 #include <Protocol/FormBrowser2.h>
25 #include <Protocol/LoadedImage.h>
26 #include <Protocol/FirmwareVolume2.h>
27 #include <Protocol/PciIo.h>
28 #include <Protocol/BusSpecificDriverOverride.h>
29 #include <Protocol/ComponentName2.h>
30 #include <Protocol/ComponentName.h>
31 #include <Protocol/DriverBinding.h>
32 #include <Protocol/DevicePathToText.h>
33 #include <Protocol/DevicePath.h>
34 #include <Protocol/PlatformDriverOverride.h>
35 #include <Guid/MdeModuleHii.h>
36 #include <Guid/VariableFormat.h>
38 #include <Library/BaseLib.h>
39 #include <Library/DebugLib.h>
40 #include <Library/UefiLib.h>
41 #include <Library/PrintLib.h>
42 #include <Library/UefiDriverEntryPoint.h>
43 #include <Library/UefiBootServicesTableLib.h>
44 #include <Library/UefiRuntimeServicesTableLib.h>
45 #include <Library/BaseMemoryLib.h>
46 #include <Library/MemoryAllocationLib.h>
47 #include <Library/DevicePathLib.h>
48 #include <Library/DxeServicesTableLib.h>
49 #include <Library/HiiLib.h>
52 Free all the mapping database memory resource and initialize the mapping list entry.
54 @param MappingDataBase Mapping database list entry pointer
56 @retval EFI_INVALID_PARAMETER mapping database list entry is NULL
57 @retval EFI_SUCCESS Free success
63 IN OUT LIST_ENTRY
*MappingDataBase
68 Read the NV environment variable(s) that contain the override mappings from Controller Device Path to
69 a set of Driver Device Paths, and create the mapping database in memory to contain these variable info.
71 @param MappingDataBase Mapping database list entry pointer
73 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
74 @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable
75 @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted
76 @retval EFI_SUCCESS Create the mapping database in memory successfully
81 InitOverridesMapping (
82 OUT LIST_ENTRY
*MappingDataBase
87 Save the memory mapping database into NV environment variable(s).
88 If MappingDataBase list is empty, then delete all platform override NV variables.
90 @param MappingDataBase Mapping database list entry pointer
92 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
93 @retval EFI_SUCCESS Save memory mapping database successfully
98 SaveOverridesMapping (
99 IN LIST_ENTRY
*MappingDataBase
104 Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.
106 @param ControllerHandle The device handle of the controller to check if
107 a driver override exists.
108 @param DriverImageHandle On output, a pointer to the next driver handle.
109 Passing in a pointer to NULL, will return the
110 first driver handle for ControllerHandle.
111 @param MappingDataBase MappingDataBase - Mapping database list entry
113 @param CallerImageHandle The caller driver's image handle, for
114 UpdateFvFileDevicePath use.
116 @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not
117 a valid handle. Or DriverImagePath is not a
118 device path that was returned on a previous call
120 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not
122 @retval EFI_UNSUPPORTED The operation is not supported.
123 @retval EFI_SUCCESS The driver override for ControllerHandle was
124 returned in DriverImagePath.
129 GetDriverFromMapping (
130 IN EFI_HANDLE ControllerHandle
,
131 IN OUT EFI_HANDLE
*DriverImageHandle
,
132 IN LIST_ENTRY
*MappingDataBase
,
133 IN EFI_HANDLE CallerImageHandle
138 Check mapping database whether already has the mapping info which
139 records the input Controller to input DriverImage.
141 @param ControllerDevicePath The controller device path is to be check.
142 @param DriverImageDevicePath The driver image device path is to be check.
143 @param MappingDataBase Mapping database list entry pointer
144 @param DriverInfoNum the controller's total override driver number
145 @param DriverImageNO The driver order number for the input DriverImage.
146 If the DriverImageDevicePath is NULL, DriverImageNO is not set.
148 @retval EFI_INVALID_PARAMETER ControllerDevicePath or MappingDataBase is NULL.
149 @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or
150 DriverImageDevicePath is not found in the found DriverImage Info list.
151 @retval EFI_SUCCESS The controller's total override driver number and
152 input DriverImage's order number is correctly return.
157 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
158 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath OPTIONAL
,
159 IN LIST_ENTRY
*MappingDataBase
,
160 OUT UINT32
*DriverInfoNum OPTIONAL
,
161 OUT UINT32
*DriverImageNO OPTIONAL
166 Insert a driver image as a controller's override driver into the mapping database.
167 The driver image's order number is indicated by DriverImageNO.
169 @param ControllerDevicePath The controller device path need to add a
170 override driver image item
171 @param DriverImageDevicePath The driver image device path need to be insert
172 @param MappingDataBase Mapping database list entry pointer
173 @param DriverImageNO The inserted order number. If this number is taken,
174 the larger available number will be used.
176 @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or DriverImageDevicePath is NULL
177 or MappingDataBase is NULL
178 @retval EFI_ALREADY_STARTED The input Controller to input DriverImage has been
179 recorded into the mapping database.
180 @retval EFI_SUCCESS The Controller and DriverImage are inserted into
181 the mapping database successfully.
187 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
188 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
189 IN LIST_ENTRY
*MappingDataBase
,
190 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