]>
Commit | Line | Data |
---|---|---|
5f597758 LG |
1 | /** @file\r |
2 | \r | |
3 | This library provides basic platform driver override functions.\r | |
4 | \r | |
5 | Copyright (c) 2007 - 2008, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
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 | |
16 | #ifndef _PLAT_DRI_OVER_LIB_H_\r | |
17 | #define _PLAT_DRI_OVER_LIB_H_\r | |
18 | \r | |
5f597758 LG |
19 | #include <Protocol/PlatformDriverOverride.h>\r |
20 | #include <Protocol/DevicePath.h>\r | |
21 | #include <Protocol/DriverBinding.h>\r | |
22 | #include <Library/BaseLib.h>\r | |
23 | \r | |
24 | #include <VariableFormat.h>\r | |
25 | \r | |
b290614d | 26 | /**\r |
27 | Install the Platform Driver Override Protocol, and ensure there is only one Platform Driver Override Protocol\r | |
28 | in the system.\r | |
29 | \r | |
30 | @param gPlatformDriverOverride PlatformDriverOverride protocol interface which\r | |
31 | needs to be installed\r | |
32 | \r | |
33 | @retval EFI_ALREADY_STARTED There has been a Platform Driver Override\r | |
34 | Protocol in the system, cannot install it again.\r | |
5f597758 LG |
35 | @retval EFI_SUCCESS The protocol is installed successfully.\r |
36 | \r | |
37 | **/\r | |
38 | EFI_STATUS\r | |
39 | EFIAPI\r | |
40 | InstallPlatformDriverOverrideProtocol (\r | |
41 | EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *gPlatformDriverOverride\r | |
42 | );\r | |
43 | \r | |
b290614d | 44 | /**\r |
5f597758 | 45 | Free all the mapping database memory resource and initialize the mapping list entry.\r |
b290614d | 46 | \r |
47 | @param MappingDataBase Mapping database list entry pointer\r | |
48 | \r | |
49 | @retval EFI_INVALID_PARAMETER mapping database list entry is NULL\r | |
50 | @retval EFI_SUCCESS Free success\r | |
51 | \r | |
5f597758 LG |
52 | **/\r |
53 | EFI_STATUS\r | |
54 | EFIAPI\r | |
55 | FreeMappingDatabase (\r | |
56 | IN OUT LIST_ENTRY *MappingDataBase\r | |
57 | );\r | |
58 | \r | |
b290614d | 59 | /**\r |
60 | Read the environment variable(s) that contain the override mappings from Controller Device Path to\r | |
61 | a set of Driver Device Paths, and create the mapping database in memory with those variable info.\r | |
b290614d | 62 | \r |
63 | @param MappingDataBase Mapping database list entry pointer\r | |
64 | \r | |
65 | @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r | |
66 | @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable\r | |
67 | @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted\r | |
5f597758 LG |
68 | @retval EFI_SUCCESS Create the mapping database in memory successfully\r |
69 | \r | |
70 | **/\r | |
71 | EFI_STATUS\r | |
72 | EFIAPI\r | |
73 | InitOverridesMapping (\r | |
74 | OUT LIST_ENTRY *MappingDataBase\r | |
75 | );\r | |
76 | \r | |
b290614d | 77 | /**\r |
5f597758 | 78 | Save the memory mapping database into NV environment variable(s).\r |
b290614d | 79 | \r |
80 | @param MappingDataBase Mapping database list entry pointer\r | |
81 | \r | |
82 | @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r | |
83 | @retval EFI_SUCCESS Save memory mapping database successfully\r | |
84 | \r | |
5f597758 LG |
85 | **/\r |
86 | EFI_STATUS\r | |
87 | EFIAPI\r | |
88 | SaveOverridesMapping (\r | |
89 | IN LIST_ENTRY *MappingDataBase\r | |
90 | );\r | |
91 | \r | |
b290614d | 92 | /**\r |
93 | Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.\r | |
94 | \r | |
5f597758 | 95 | @param This A pointer to the EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.\r |
b290614d | 96 | @param ControllerHandle The device handle of the controller to check if\r |
97 | a driver override exists.\r | |
98 | @param DriverImageHandle On output, a pointer to the next driver handle.\r | |
99 | Passing in a pointer to NULL, will return the\r | |
100 | first driver handle for ControllerHandle.\r | |
101 | @param MappingDataBase MappingDataBase - Mapping database list entry\r | |
102 | pointer\r | |
103 | @param CallerImageHandle The caller driver's image handle, for\r | |
104 | UpdateFvFileDevicePath use.\r | |
105 | \r | |
106 | @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not\r | |
107 | a valid handle. Or DriverImagePath is not a\r | |
108 | device path that was returned on a previous call\r | |
109 | to GetDriverPath().\r | |
110 | @retval EFI_NOT_FOUND A driver override for ControllerHandle was not\r | |
111 | found.\r | |
112 | @retval EFI_UNSUPPORTED The operation is not supported.\r | |
113 | @retval EFI_SUCCESS The driver override for ControllerHandle was\r | |
114 | returned in DriverImagePath.\r | |
115 | \r | |
5f597758 LG |
116 | **/\r |
117 | EFI_STATUS\r | |
118 | EFIAPI\r | |
119 | GetDriverFromMapping (\r | |
120 | IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,\r | |
121 | IN EFI_HANDLE ControllerHandle,\r | |
122 | IN OUT EFI_HANDLE * DriverImageHandle,\r | |
123 | IN LIST_ENTRY * MappingDataBase,\r | |
124 | IN EFI_HANDLE CallerImageHandle\r | |
125 | );\r | |
126 | \r | |
127 | /**\r | |
128 | Deletes all environment variable(s) that contain the override mappings from Controller Device Path to\r | |
129 | a set of Driver Device Paths.\r | |
130 | \r | |
131 | @retval EFI_SUCCESS Delete all variable(s) successfully.\r | |
132 | **/\r | |
133 | EFI_STATUS\r | |
134 | EFIAPI\r | |
135 | DeleteOverridesVariables (\r | |
136 | VOID\r | |
137 | );\r | |
138 | \r | |
b290614d | 139 | /**\r |
140 | Check mapping database whether already has the mapping info which\r | |
141 | records the input Controller to input DriverImage.\r | |
b290614d | 142 | \r |
5f597758 LG |
143 | @param ControllerDevicePath The controller device path is to be check.\r |
144 | @param DriverImageDevicePath The driver image device path is to be check.\r | |
b290614d | 145 | @param MappingDataBase Mapping database list entry pointer\r |
146 | @param DriverInfoNum the controller's total override driver number\r | |
5f597758 LG |
147 | @param DriverImageNO The driver order number for the input DriverImage.\r |
148 | If the DriverImageDevicePath is NULL, DriverImageNO is not set.\r | |
149 | \r | |
150 | @retval EFI_INVALID_PARAMETER ControllerDevicePath or MappingDataBase is NULL.\r | |
151 | @retval EFI_NOT_FOUND ControllerDevicePath is not found in MappingDataBase or\r | |
152 | DriverImageDevicePath is not found in the found DriverImage Info list. \r | |
153 | @retval EFI_SUCCESS The controller's total override driver number and \r | |
154 | input DriverImage's order number is correctly return.\r | |
155 | **/\r | |
156 | EFI_STATUS\r | |
157 | EFIAPI\r | |
158 | CheckMapping (\r | |
159 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
160 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,\r | |
161 | IN LIST_ENTRY * MappingDataBase,\r | |
162 | OUT UINT32 *DriverInfoNum,\r | |
163 | OUT UINT32 *DriverImageNO\r | |
164 | );\r | |
165 | \r | |
b290614d | 166 | /**\r |
167 | Insert a driver image as a controller's override driver into the mapping database.\r | |
168 | The driver image's order number is indicated by DriverImageNO.\r | |
169 | \r | |
170 | @param ControllerDevicePath The controller device path need to add a\r | |
171 | override driver image item\r | |
172 | @param DriverImageDevicePath The driver image device path need to be insert\r | |
173 | @param MappingDataBase Mapping database list entry pointer\r | |
5f597758 LG |
174 | @param DriverImageNO The inserted order number. If this number is taken, \r |
175 | the larger available number will be used.\r | |
176 | \r | |
177 | @retval EFI_INVALID_PARAMETER ControllerDevicePath is NULL, or DriverImageDevicePath is NULL\r | |
178 | or MappingDataBase is NULL\r | |
179 | @retval EFI_ALREADY_STARTED The input Controller to input DriverImage has been \r | |
180 | recorded into the mapping database.\r | |
181 | @retval EFI_SUCCESS The Controller and DriverImage are inserted into \r | |
182 | the mapping database successfully.\r | |
183 | \r | |
184 | **/\r | |
185 | EFI_STATUS\r | |
186 | EFIAPI\r | |
187 | InsertDriverImage (\r | |
188 | IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,\r | |
189 | IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,\r | |
190 | IN LIST_ENTRY *MappingDataBase,\r | |
191 | IN UINT32 DriverImageNO\r | |
192 | );\r | |
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 | |
215 | );\r | |
216 | \r | |
3012ce5c | 217 | /**\r |
218 | Get the first Binding protocol which has the specific image handle\r | |
219 | \r | |
5f597758 LG |
220 | @param ImageHandle The Image handle\r |
221 | @param BindingHandle The BindingHandle of the found Driver Binding protocol.\r | |
222 | If Binding protocol is not found, it is set to NULL. \r | |
3012ce5c | 223 | \r |
5f597758 LG |
224 | @return Pointer into the Binding Protocol interface\r |
225 | @retval NULL The paramter is not valid or the binding protocol is not found.\r | |
3012ce5c | 226 | \r |
227 | **/\r | |
228 | EFI_DRIVER_BINDING_PROTOCOL *\r | |
229 | EFIAPI\r | |
230 | GetBindingProtocolFromImageHandle (\r | |
231 | IN EFI_HANDLE ImageHandle,\r | |
232 | OUT EFI_HANDLE *BindingHandle\r | |
5f597758 LG |
233 | );\r |
234 | \r | |
235 | #endif\r |