]>
Commit | Line | Data |
---|---|---|
5f597758 | 1 | /** @file\r |
6d8ced29 LG |
2 | Ihe internal heder file includes the required Protocol/Guid/Library\r |
3 | and the shared function APIs.\r | |
5f597758 | 4 | \r |
863986b3 | 5 | Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 6 | This program and the accompanying materials\r |
5f597758 LG |
7 | are licensed and made available under the terms and conditions of the BSD License\r |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
6d8ced29 LG |
16 | #ifndef _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_\r |
17 | #define _INTERNAL_PLATFORM_DRIVER_OVERRIDE_H_\r | |
18 | \r | |
19 | #include <PiDxe.h>\r | |
20 | \r | |
21 | #include <Protocol/HiiConfigAccess.h>\r | |
22 | #include <Protocol/HiiConfigRouting.h>\r | |
23 | #include <Protocol/HiiDatabase.h>\r | |
24 | #include <Protocol/FormBrowser2.h>\r | |
25 | #include <Protocol/LoadedImage.h>\r | |
26 | #include <Protocol/FirmwareVolume2.h>\r | |
27 | #include <Protocol/PciIo.h>\r | |
28 | #include <Protocol/BusSpecificDriverOverride.h>\r | |
29 | #include <Protocol/ComponentName2.h>\r | |
30 | #include <Protocol/ComponentName.h>\r | |
31 | #include <Protocol/DriverBinding.h>\r | |
5f597758 | 32 | #include <Protocol/DevicePath.h>\r |
6d8ced29 LG |
33 | #include <Protocol/PlatformDriverOverride.h>\r |
34 | #include <Guid/MdeModuleHii.h>\r | |
35 | #include <Guid/VariableFormat.h>\r | |
36 | \r | |
37 | #include <Library/BaseLib.h>\r | |
38 | #include <Library/DebugLib.h>\r | |
39 | #include <Library/UefiLib.h>\r | |
40 | #include <Library/PrintLib.h>\r | |
41 | #include <Library/UefiDriverEntryPoint.h>\r | |
42 | #include <Library/UefiBootServicesTableLib.h>\r | |
43 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
44 | #include <Library/BaseMemoryLib.h>\r | |
45 | #include <Library/MemoryAllocationLib.h>\r | |
46 | #include <Library/DevicePathLib.h>\r | |
47 | #include <Library/DxeServicesTableLib.h>\r | |
48 | #include <Library/HiiLib.h>\r | |
5f597758 | 49 | \r |
b290614d | 50 | /**\r |
5f597758 | 51 | Free all the mapping database memory resource and initialize the mapping list entry.\r |
b290614d | 52 | \r |
53 | @param MappingDataBase Mapping database list entry pointer\r | |
54 | \r | |
55 | @retval EFI_INVALID_PARAMETER mapping database list entry is NULL\r | |
56 | @retval EFI_SUCCESS Free success\r | |
57 | \r | |
5f597758 LG |
58 | **/\r |
59 | EFI_STATUS\r | |
60 | EFIAPI\r | |
61 | FreeMappingDatabase (\r | |
62 | IN OUT LIST_ENTRY *MappingDataBase\r | |
b9982883 | 63 | )\r |
31f228cf | 64 | ;\r |
5f597758 | 65 | \r |
b290614d | 66 | /**\r |
68dbca6c LG |
67 | Read the NV environment variable(s) that contain the override mappings from Controller Device Path to\r |
68 | a set of Driver Device Paths, and create the mapping database in memory to contain these variable info.\r | |
b290614d | 69 | \r |
70 | @param MappingDataBase Mapping database list entry pointer\r | |
71 | \r | |
72 | @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r | |
73 | @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable\r | |
74 | @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted\r | |
5f597758 LG |
75 | @retval EFI_SUCCESS Create the mapping database in memory successfully\r |
76 | \r | |
77 | **/\r | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | InitOverridesMapping (\r | |
81 | OUT LIST_ENTRY *MappingDataBase\r | |
b9982883 | 82 | )\r |
31f228cf | 83 | ;\r |
5f597758 | 84 | \r |
b290614d | 85 | /**\r |
5f597758 | 86 | Save the memory mapping database into NV environment variable(s).\r |
68dbca6c | 87 | If MappingDataBase list is empty, then delete all platform override NV variables.\r |
b290614d | 88 | \r |
89 | @param MappingDataBase Mapping database list entry pointer\r | |
90 | \r | |
91 | @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r | |
92 | @retval EFI_SUCCESS Save memory mapping database successfully\r | |
93 | \r | |
5f597758 LG |
94 | **/\r |
95 | EFI_STATUS\r | |
96 | EFIAPI\r | |
97 | SaveOverridesMapping (\r | |
98 | IN LIST_ENTRY *MappingDataBase\r | |
b9982883 | 99 | )\r |
31f228cf | 100 | ;\r |
5f597758 | 101 | \r |
b290614d | 102 | /**\r |
103 | Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.\r | |
104 | \r | |
b290614d | 105 | @param ControllerHandle The device handle of the controller to check if\r |
106 | a driver override exists.\r | |
107 | @param DriverImageHandle On output, a pointer to the next driver handle.\r | |
108 | Passing in a pointer to NULL, will return the\r | |
109 | first driver handle for ControllerHandle.\r | |
110 | @param MappingDataBase MappingDataBase - Mapping database list entry\r | |
111 | pointer\r | |
112 | @param CallerImageHandle The caller driver's image handle, for\r | |
113 | UpdateFvFileDevicePath use.\r | |
114 | \r | |
115 | @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not\r | |
116 | a valid handle. Or DriverImagePath is not a\r | |
117 | device path that was returned on a previous call\r | |
118 | to GetDriverPath().\r | |
119 | @retval EFI_NOT_FOUND A driver override for ControllerHandle was not\r | |
120 | found.\r | |
121 | @retval EFI_UNSUPPORTED The operation is not supported.\r | |
122 | @retval EFI_SUCCESS The driver override for ControllerHandle was\r | |
123 | returned in DriverImagePath.\r | |
124 | \r | |
5f597758 LG |
125 | **/\r |
126 | EFI_STATUS\r | |
127 | EFIAPI\r | |
128 | GetDriverFromMapping (\r | |
5f597758 | 129 | IN EFI_HANDLE ControllerHandle,\r |
68dbca6c LG |
130 | IN OUT EFI_HANDLE *DriverImageHandle,\r |
131 | IN LIST_ENTRY *MappingDataBase,\r | |
5f597758 | 132 | IN EFI_HANDLE CallerImageHandle\r |
b9982883 | 133 | )\r |
31f228cf | 134 | ;\r |
5f597758 LG |
135 | \r |
136 | /**\r | |
68dbca6c | 137 | Check mapping database whether already has the mapping info which\r |
b290614d | 138 | records the input Controller to input DriverImage.\r |
b290614d | 139 | \r |
5f597758 LG |
140 | @param ControllerDevicePath The controller device path is to be check.\r |
141 | @param DriverImageDevicePath The driver image device path is to be check.\r | |
b290614d | 142 | @param MappingDataBase Mapping database list entry pointer\r |
143 | @param DriverInfoNum the controller's total override driver number\r | |
5f597758 LG |
144 | @param DriverImageNO The driver order number for the input DriverImage.\r |
145 | If the DriverImageDevicePath is NULL, DriverImageNO is not set.\r | |
146 | \r | |
147 | @retval EFI_INVALID_PARAMETER ControllerDevicePath or MappingDataBase is NULL.\r | |
148 | @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or\r | |
149 | DriverImageDevicePath is not found in the found DriverImage Info list. \r | |
150 | @retval EFI_SUCCESS The controller's total override driver number and \r | |
151 | input DriverImage's order number is correctly return.\r | |
152 | **/\r | |
153 | EFI_STATUS\r | |
154 | EFIAPI\r | |
155 | CheckMapping (\r | |
156 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
0bcd9130 | 157 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath OPTIONAL,\r |
158 | IN LIST_ENTRY *MappingDataBase,\r | |
159 | OUT UINT32 *DriverInfoNum OPTIONAL,\r | |
160 | OUT UINT32 *DriverImageNO OPTIONAL\r | |
b9982883 | 161 | )\r |
31f228cf | 162 | ;\r |
5f597758 | 163 | \r |
b290614d | 164 | /**\r |
165 | Insert a driver image as a controller's override driver into the mapping database.\r | |
166 | The driver image's order number is indicated by DriverImageNO.\r | |
167 | \r | |
168 | @param ControllerDevicePath The controller device path need to add a\r | |
169 | override driver image item\r | |
170 | @param DriverImageDevicePath The driver image device path need to be insert\r | |
171 | @param MappingDataBase Mapping database list entry pointer\r | |
5f597758 LG |
172 | @param DriverImageNO The inserted order number. If this number is taken, \r |
173 | the larger available number will be used.\r | |
174 | \r | |
175 | @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or DriverImageDevicePath is NULL\r | |
176 | or MappingDataBase is NULL\r | |
177 | @retval EFI_ALREADY_STARTED The input Controller to input DriverImage has been \r | |
178 | recorded into the mapping database.\r | |
179 | @retval EFI_SUCCESS The Controller and DriverImage are inserted into \r | |
180 | the mapping database successfully.\r | |
181 | \r | |
182 | **/\r | |
183 | EFI_STATUS\r | |
184 | EFIAPI\r | |
185 | InsertDriverImage (\r | |
186 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
187 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,\r | |
188 | IN LIST_ENTRY *MappingDataBase,\r | |
189 | IN UINT32 DriverImageNO\r | |
b9982883 | 190 | )\r |
31f228cf | 191 | ;\r |
5f597758 | 192 | \r |
b290614d | 193 | /**\r |
194 | Delete a controller's override driver from the mapping database.\r | |
195 | \r | |
5f597758 LG |
196 | @param ControllerDevicePath The controller device path will be deleted \r |
197 | when all drivers images on it are removed.\r | |
198 | @param DriverImageDevicePath The driver image device path will be delete.\r | |
199 | If NULL, all driver image will be delete.\r | |
b290614d | 200 | @param MappingDataBase Mapping database list entry pointer\r |
5f597758 LG |
201 | \r |
202 | @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or MappingDataBase is NULL\r | |
203 | @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or\r | |
204 | DriverImageDevicePath is not found in the found DriverImage Info list. \r | |
205 | @retval EFI_SUCCESS Delete the specified driver successfully.\r | |
206 | \r | |
207 | **/\r | |
208 | EFI_STATUS\r | |
209 | EFIAPI\r | |
210 | DeleteDriverImage (\r | |
211 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
212 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,\r | |
213 | IN LIST_ENTRY *MappingDataBase\r | |
b9982883 | 214 | )\r |
31f228cf | 215 | ;\r |
5f597758 | 216 | \r |
5f597758 | 217 | #endif\r |