]>
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 |
e5eed7d3 HT |
5 | Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r |
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 | |
32 | #include <Protocol/DevicePathToText.h>\r | |
5f597758 | 33 | #include <Protocol/DevicePath.h>\r |
6d8ced29 LG |
34 | #include <Protocol/PlatformDriverOverride.h>\r |
35 | #include <Guid/MdeModuleHii.h>\r | |
36 | #include <Guid/VariableFormat.h>\r | |
37 | \r | |
38 | #include <Library/BaseLib.h>\r | |
39 | #include <Library/DebugLib.h>\r | |
40 | #include <Library/UefiLib.h>\r | |
41 | #include <Library/PrintLib.h>\r | |
42 | #include <Library/UefiDriverEntryPoint.h>\r | |
43 | #include <Library/UefiBootServicesTableLib.h>\r | |
44 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
45 | #include <Library/BaseMemoryLib.h>\r | |
46 | #include <Library/MemoryAllocationLib.h>\r | |
47 | #include <Library/DevicePathLib.h>\r | |
48 | #include <Library/DxeServicesTableLib.h>\r | |
49 | #include <Library/HiiLib.h>\r | |
5f597758 | 50 | \r |
b290614d | 51 | /**\r |
5f597758 | 52 | Free all the mapping database memory resource and initialize the mapping list entry.\r |
b290614d | 53 | \r |
54 | @param MappingDataBase Mapping database list entry pointer\r | |
55 | \r | |
56 | @retval EFI_INVALID_PARAMETER mapping database list entry is NULL\r | |
57 | @retval EFI_SUCCESS Free success\r | |
58 | \r | |
5f597758 LG |
59 | **/\r |
60 | EFI_STATUS\r | |
61 | EFIAPI\r | |
62 | FreeMappingDatabase (\r | |
63 | IN OUT LIST_ENTRY *MappingDataBase\r | |
b9982883 | 64 | )\r |
31f228cf | 65 | ;\r |
5f597758 | 66 | \r |
b290614d | 67 | /**\r |
68dbca6c LG |
68 | Read the NV environment variable(s) that contain the override mappings from Controller Device Path to\r |
69 | a set of Driver Device Paths, and create the mapping database in memory to contain these variable info.\r | |
b290614d | 70 | \r |
71 | @param MappingDataBase Mapping database list entry pointer\r | |
72 | \r | |
73 | @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r | |
74 | @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable\r | |
75 | @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted\r | |
5f597758 LG |
76 | @retval EFI_SUCCESS Create the mapping database in memory successfully\r |
77 | \r | |
78 | **/\r | |
79 | EFI_STATUS\r | |
80 | EFIAPI\r | |
81 | InitOverridesMapping (\r | |
82 | OUT LIST_ENTRY *MappingDataBase\r | |
b9982883 | 83 | )\r |
31f228cf | 84 | ;\r |
5f597758 | 85 | \r |
b290614d | 86 | /**\r |
5f597758 | 87 | Save the memory mapping database into NV environment variable(s).\r |
68dbca6c | 88 | If MappingDataBase list is empty, then delete all platform override NV variables.\r |
b290614d | 89 | \r |
90 | @param MappingDataBase Mapping database list entry pointer\r | |
91 | \r | |
92 | @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r | |
93 | @retval EFI_SUCCESS Save memory mapping database successfully\r | |
94 | \r | |
5f597758 LG |
95 | **/\r |
96 | EFI_STATUS\r | |
97 | EFIAPI\r | |
98 | SaveOverridesMapping (\r | |
99 | IN LIST_ENTRY *MappingDataBase\r | |
b9982883 | 100 | )\r |
31f228cf | 101 | ;\r |
5f597758 | 102 | \r |
b290614d | 103 | /**\r |
104 | Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.\r | |
105 | \r | |
b290614d | 106 | @param ControllerHandle The device handle of the controller to check if\r |
107 | a driver override exists.\r | |
108 | @param DriverImageHandle On output, a pointer to the next driver handle.\r | |
109 | Passing in a pointer to NULL, will return the\r | |
110 | first driver handle for ControllerHandle.\r | |
111 | @param MappingDataBase MappingDataBase - Mapping database list entry\r | |
112 | pointer\r | |
113 | @param CallerImageHandle The caller driver's image handle, for\r | |
114 | UpdateFvFileDevicePath use.\r | |
115 | \r | |
116 | @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not\r | |
117 | a valid handle. Or DriverImagePath is not a\r | |
118 | device path that was returned on a previous call\r | |
119 | to GetDriverPath().\r | |
120 | @retval EFI_NOT_FOUND A driver override for ControllerHandle was not\r | |
121 | found.\r | |
122 | @retval EFI_UNSUPPORTED The operation is not supported.\r | |
123 | @retval EFI_SUCCESS The driver override for ControllerHandle was\r | |
124 | returned in DriverImagePath.\r | |
125 | \r | |
5f597758 LG |
126 | **/\r |
127 | EFI_STATUS\r | |
128 | EFIAPI\r | |
129 | GetDriverFromMapping (\r | |
5f597758 | 130 | IN EFI_HANDLE ControllerHandle,\r |
68dbca6c LG |
131 | IN OUT EFI_HANDLE *DriverImageHandle,\r |
132 | IN LIST_ENTRY *MappingDataBase,\r | |
5f597758 | 133 | IN EFI_HANDLE CallerImageHandle\r |
b9982883 | 134 | )\r |
31f228cf | 135 | ;\r |
5f597758 LG |
136 | \r |
137 | /**\r | |
68dbca6c | 138 | Check mapping database whether already has the mapping info which\r |
b290614d | 139 | records the input Controller to input DriverImage.\r |
b290614d | 140 | \r |
5f597758 LG |
141 | @param ControllerDevicePath The controller device path is to be check.\r |
142 | @param DriverImageDevicePath The driver image device path is to be check.\r | |
b290614d | 143 | @param MappingDataBase Mapping database list entry pointer\r |
144 | @param DriverInfoNum the controller's total override driver number\r | |
5f597758 LG |
145 | @param DriverImageNO The driver order number for the input DriverImage.\r |
146 | If the DriverImageDevicePath is NULL, DriverImageNO is not set.\r | |
147 | \r | |
148 | @retval EFI_INVALID_PARAMETER ControllerDevicePath or MappingDataBase is NULL.\r | |
149 | @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or\r | |
150 | DriverImageDevicePath is not found in the found DriverImage Info list. \r | |
151 | @retval EFI_SUCCESS The controller's total override driver number and \r | |
152 | input DriverImage's order number is correctly return.\r | |
153 | **/\r | |
154 | EFI_STATUS\r | |
155 | EFIAPI\r | |
156 | CheckMapping (\r | |
157 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
0bcd9130 | 158 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath OPTIONAL,\r |
159 | IN LIST_ENTRY *MappingDataBase,\r | |
160 | OUT UINT32 *DriverInfoNum OPTIONAL,\r | |
161 | OUT UINT32 *DriverImageNO OPTIONAL\r | |
b9982883 | 162 | )\r |
31f228cf | 163 | ;\r |
5f597758 | 164 | \r |
b290614d | 165 | /**\r |
166 | Insert a driver image as a controller's override driver into the mapping database.\r | |
167 | The driver image's order number is indicated by DriverImageNO.\r | |
168 | \r | |
169 | @param ControllerDevicePath The controller device path need to add a\r | |
170 | override driver image item\r | |
171 | @param DriverImageDevicePath The driver image device path need to be insert\r | |
172 | @param MappingDataBase Mapping database list entry pointer\r | |
5f597758 LG |
173 | @param DriverImageNO The inserted order number. If this number is taken, \r |
174 | the larger available number will be used.\r | |
175 | \r | |
176 | @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or DriverImageDevicePath is NULL\r | |
177 | or MappingDataBase is NULL\r | |
178 | @retval EFI_ALREADY_STARTED The input Controller to input DriverImage has been \r | |
179 | recorded into the mapping database.\r | |
180 | @retval EFI_SUCCESS The Controller and DriverImage are inserted into \r | |
181 | the mapping database successfully.\r | |
182 | \r | |
183 | **/\r | |
184 | EFI_STATUS\r | |
185 | EFIAPI\r | |
186 | InsertDriverImage (\r | |
187 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
188 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,\r | |
189 | IN LIST_ENTRY *MappingDataBase,\r | |
190 | IN UINT32 DriverImageNO\r | |
b9982883 | 191 | )\r |
31f228cf | 192 | ;\r |
5f597758 | 193 | \r |
b290614d | 194 | /**\r |
195 | Delete a controller's override driver from the mapping database.\r | |
196 | \r | |
5f597758 LG |
197 | @param ControllerDevicePath The controller device path will be deleted \r |
198 | when all drivers images on it are removed.\r | |
199 | @param DriverImageDevicePath The driver image device path will be delete.\r | |
200 | If NULL, all driver image will be delete.\r | |
b290614d | 201 | @param MappingDataBase Mapping database list entry pointer\r |
5f597758 LG |
202 | \r |
203 | @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or MappingDataBase is NULL\r | |
204 | @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or\r | |
205 | DriverImageDevicePath is not found in the found DriverImage Info list. \r | |
206 | @retval EFI_SUCCESS Delete the specified driver successfully.\r | |
207 | \r | |
208 | **/\r | |
209 | EFI_STATUS\r | |
210 | EFIAPI\r | |
211 | DeleteDriverImage (\r | |
212 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
213 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,\r | |
214 | IN LIST_ENTRY *MappingDataBase\r | |
b9982883 | 215 | )\r |
31f228cf | 216 | ;\r |
5f597758 | 217 | \r |
5f597758 | 218 | #endif\r |