]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PlatformDriOverrideDxe/InternalPlatDriOverrideDxe.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / PlatformDriOverrideDxe / InternalPlatDriOverrideDxe.h
1 /** @file
2 Ihe internal heder file includes the required Protocol/Guid/Library
3 and the shared function APIs.
4
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_
11 #define _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_
12
13 #include <PiDxe.h>
14
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>
30
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>
43
44 /**
45 Free all the mapping database memory resource and initialize the mapping list entry.
46
47 @param MappingDataBase Mapping database list entry pointer
48
49 @retval EFI_INVALID_PARAMETER mapping database list entry is NULL
50 @retval EFI_SUCCESS Free success
51
52 **/
53 EFI_STATUS
54 EFIAPI
55 FreeMappingDatabase (
56 IN OUT LIST_ENTRY *MappingDataBase
57 )
58 ;
59
60 /**
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.
63
64 @param MappingDataBase Mapping database list entry pointer
65
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
70
71 **/
72 EFI_STATUS
73 EFIAPI
74 InitOverridesMapping (
75 OUT LIST_ENTRY *MappingDataBase
76 )
77 ;
78
79 /**
80 Save the memory mapping database into NV environment variable(s).
81 If MappingDataBase list is empty, then delete all platform override NV variables.
82
83 @param MappingDataBase Mapping database list entry pointer
84
85 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null
86 @retval EFI_SUCCESS Save memory mapping database successfully
87
88 **/
89 EFI_STATUS
90 EFIAPI
91 SaveOverridesMapping (
92 IN LIST_ENTRY *MappingDataBase
93 )
94 ;
95
96 /**
97 Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.
98
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
105 pointer
106 @param CallerImageHandle The caller driver's image handle, for
107 UpdateFvFileDevicePath use.
108
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
112 to GetDriverPath().
113 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not
114 found.
115 @retval EFI_UNSUPPORTED The operation is not supported.
116 @retval EFI_SUCCESS The driver override for ControllerHandle was
117 returned in DriverImagePath.
118
119 **/
120 EFI_STATUS
121 EFIAPI
122 GetDriverFromMapping (
123 IN EFI_HANDLE ControllerHandle,
124 IN OUT EFI_HANDLE *DriverImageHandle,
125 IN LIST_ENTRY *MappingDataBase,
126 IN EFI_HANDLE CallerImageHandle
127 )
128 ;
129
130 /**
131 Check mapping database whether already has the mapping info which
132 records the input Controller to input DriverImage.
133
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.
140
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.
146 **/
147 EFI_STATUS
148 EFIAPI
149 CheckMapping (
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
155 )
156 ;
157
158 /**
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.
161
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.
168
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.
175
176 **/
177 EFI_STATUS
178 EFIAPI
179 InsertDriverImage (
180 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
181 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
182 IN LIST_ENTRY *MappingDataBase,
183 IN UINT32 DriverImageNO
184 )
185 ;
186
187 /**
188 Delete a controller's override driver from the mapping database.
189
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
195
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.
200
201 **/
202 EFI_STATUS
203 EFIAPI
204 DeleteDriverImage (
205 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
206 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
207 IN LIST_ENTRY *MappingDataBase
208 )
209 ;
210
211 #endif