2 Ihe internal heder file includes the required Protocol/Guid/Library
3 and the shared function APIs.
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_
11 #define _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_
15 #include <Protocol/HiiConfigAccess.h>
16 #include <Protocol/HiiConfigRouting.h>
17 #include <Protocol/HiiDatabase.h>
18 #include <Protocol/FormBrowser2.h>
19 #include <Protocol/LoadedImage.h>
20 #include <Protocol/FirmwareVolume2.h>
21 #include <Protocol/PciIo.h>
22 #include <Protocol/BusSpecificDriverOverride.h>
23 #include <Protocol/ComponentName2.h>
24 #include <Protocol/ComponentName.h>
25 #include <Protocol/DriverBinding.h>
26 #include <Protocol/DevicePath.h>
27 #include <Protocol/PlatformDriverOverride.h>
28 #include <Guid/MdeModuleHii.h>
29 #include <Guid/VariableFormat.h>
31 #include <Library/BaseLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/UefiLib.h>
34 #include <Library/PrintLib.h>
35 #include <Library/UefiDriverEntryPoint.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiRuntimeServicesTableLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/MemoryAllocationLib.h>
40 #include <Library/DevicePathLib.h>
41 #include <Library/DxeServicesTableLib.h>
42 #include <Library/HiiLib.h>
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
61 Read the NV environment variable(s) that contain the override mappings from Controller Device Path to
62 a set of Driver Device Paths, and create the mapping database in memory to contain these variable info.
64 @param MappingDataBase Mapping database list entry pointer
66 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
67 @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable
68 @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted
69 @retval EFI_SUCCESS Create the mapping database in memory successfully
74 InitOverridesMapping (
75 OUT LIST_ENTRY
*MappingDataBase
80 Save the memory mapping database into NV environment variable(s).
81 If MappingDataBase list is empty, then delete all platform override NV variables.
83 @param MappingDataBase Mapping database list entry pointer
85 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
86 @retval EFI_SUCCESS Save memory mapping database successfully
91 SaveOverridesMapping (
92 IN LIST_ENTRY
*MappingDataBase
97 Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.
99 @param ControllerHandle The device handle of the controller to check if
100 a driver override exists.
101 @param DriverImageHandle On output, a pointer to the next driver handle.
102 Passing in a pointer to NULL, will return the
103 first driver handle for ControllerHandle.
104 @param MappingDataBase MappingDataBase - Mapping database list entry
106 @param CallerImageHandle The caller driver's image handle, for
107 UpdateFvFileDevicePath use.
109 @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not
110 a valid handle. Or DriverImagePath is not a
111 device path that was returned on a previous call
113 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not
115 @retval EFI_UNSUPPORTED The operation is not supported.
116 @retval EFI_SUCCESS The driver override for ControllerHandle was
117 returned in DriverImagePath.
122 GetDriverFromMapping (
123 IN EFI_HANDLE ControllerHandle
,
124 IN OUT EFI_HANDLE
*DriverImageHandle
,
125 IN LIST_ENTRY
*MappingDataBase
,
126 IN EFI_HANDLE CallerImageHandle
131 Check mapping database whether already has the mapping info which
132 records the input Controller to input DriverImage.
134 @param ControllerDevicePath The controller device path is to be check.
135 @param DriverImageDevicePath The driver image device path is to be check.
136 @param MappingDataBase Mapping database list entry pointer
137 @param DriverInfoNum the controller's total override driver number
138 @param DriverImageNO The driver order number for the input DriverImage.
139 If the DriverImageDevicePath is NULL, DriverImageNO is not set.
141 @retval EFI_INVALID_PARAMETER ControllerDevicePath or MappingDataBase is NULL.
142 @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or
143 DriverImageDevicePath is not found in the found DriverImage Info list.
144 @retval EFI_SUCCESS The controller's total override driver number and
145 input DriverImage's order number is correctly return.
150 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
151 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath OPTIONAL
,
152 IN LIST_ENTRY
*MappingDataBase
,
153 OUT UINT32
*DriverInfoNum OPTIONAL
,
154 OUT UINT32
*DriverImageNO OPTIONAL
159 Insert a driver image as a controller's override driver into the mapping database.
160 The driver image's order number is indicated by DriverImageNO.
162 @param ControllerDevicePath The controller device path need to add a
163 override driver image item
164 @param DriverImageDevicePath The driver image device path need to be insert
165 @param MappingDataBase Mapping database list entry pointer
166 @param DriverImageNO The inserted order number. If this number is taken,
167 the larger available number will be used.
169 @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or DriverImageDevicePath is NULL
170 or MappingDataBase is NULL
171 @retval EFI_ALREADY_STARTED The input Controller to input DriverImage has been
172 recorded into the mapping database.
173 @retval EFI_SUCCESS The Controller and DriverImage are inserted into
174 the mapping database successfully.
180 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
181 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
182 IN LIST_ENTRY
*MappingDataBase
,
183 IN UINT32 DriverImageNO
188 Delete a controller's override driver from the mapping database.
190 @param ControllerDevicePath The controller device path will be deleted
191 when all drivers images on it are removed.
192 @param DriverImageDevicePath The driver image device path will be delete.
193 If NULL, all driver image will be delete.
194 @param MappingDataBase Mapping database list entry pointer
196 @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or MappingDataBase is NULL
197 @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or
198 DriverImageDevicePath is not found in the found DriverImage Info list.
199 @retval EFI_SUCCESS Delete the specified driver successfully.
205 IN EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
,
206 IN EFI_DEVICE_PATH_PROTOCOL
*DriverImageDevicePath
,
207 IN LIST_ENTRY
*MappingDataBase