]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/PlatDriOverLib.h
1. Fixed bugs in DxeNetLib to meet consistence with network module DriverBinding...
[mirror_edk2.git] / MdeModulePkg / Include / Library / PlatDriOverLib.h
CommitLineData
b290614d 1/** @file
2
3Copyright (c) 2007, Intel Corporation
4All rights reserved. This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 PlatDriOverLib.h
15
16Abstract:
17
18
19**/
20
21#ifndef _PLAT_DRI_OVER_LIB_H_
22#define _PLAT_DRI_OVER_LIB_H_
23
24#include <PiDxe.h>
25#include <Protocol/PlatformDriverOverride.h>
26#include <Protocol/DevicePath.h>
3012ce5c 27#include <Protocol/DriverBinding.h>
b290614d 28#include <Library/BaseLib.h>
29
30#include <VariableFormat.h>
31
32/**\r
33 Install the Platform Driver Override Protocol, and ensure there is only one Platform Driver Override Protocol\r
34 in the system.\r
35\r
36 @param gPlatformDriverOverride PlatformDriverOverride protocol interface which\r
37 needs to be installed\r
38\r
39 @retval EFI_ALREADY_STARTED There has been a Platform Driver Override\r
40 Protocol in the system, cannot install it again.\r
41 @retval Other Returned by InstallProtocolInterface\r
42\r
43**/
44EFI_STATUS
45EFIAPI
46InstallPlatformDriverOverrideProtocol (
47 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *gPlatformDriverOverride
48 );
49
50/**\r
51 Free all the mapping database memory resource and initialize the mapping list entry\r
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
58**/
59EFI_STATUS
60EFIAPI
61FreeMappingDatabase (
62 IN OUT LIST_ENTRY *MappingDataBase
63 );
64
65/**\r
66 Read the environment variable(s) that contain the override mappings from Controller Device Path to\r
67 a set of Driver Device Paths, and create the mapping database in memory with those variable info.\r
68 VariableLayout{\r
69 //\r
70 // NotEnd indicate whether the variable is the last one, and has no subsequent variable need to load.\r
71 // Each variable has MaximumVariableSize limitation, so we maybe need multi variables to store\r
72 // large mapping infos.\r
73 // The variable(s) name rule is PlatDriOver, PlatDriOver1, PlatDriOver2, ....\r
74 //\r
75 UINT32 NotEnd;\r
76 //\r
77 // The entry which contains the mapping that Controller Device Path to a set of Driver Device Paths\r
78 // There are often multi mapping entries in a variable.\r
79 //\r
80 UINT32 SIGNATURE; //EFI_SIGNATURE_32('p','d','o','i')\r
81 UINT32 DriverNum;\r
82 EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];\r
83 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
84 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
85 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
86 ......\r
87 UINT32 SIGNATURE;\r
88 UINT32 DriverNum;\r
89 EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];\r
90 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
91 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
92 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
93 ......\r
94 }\r
95 typedef struct _PLATFORM_OVERRIDE_ITEM{\r
96 UINTN Signature; //EFI_SIGNATURE_32('p','d','o','i')\r
97 LIST_ENTRY Link;\r
98 UINT32 DriverInfoNum;\r
99 EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;\r
100 LIST_ENTRY DriverInfoList; //DRIVER_IMAGE_INFO List\r
101 } PLATFORM_OVERRIDE_ITEM;\r
102 typedef struct _DRIVER_IMAGE_INFO{\r
103 UINTN Signature; //EFI_SIGNATURE_32('p','d','i','i')\r
104 LIST_ENTRY Link;\r
105 EFI_HANDLE ImageHandle;\r
106 EFI_DEVICE_PATH_PROTOCOL *DriverImagePath;\r
107 BOOLEAN UnLoadable;\r
108 BOOLEAN UnStartable;\r
109 } DRIVER_IMAGE_INFO;\r
110\r
111 @param MappingDataBase Mapping database list entry pointer\r
112\r
113 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r
114 @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable\r
115 @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted\r
116 @retval EFI_SUCCESS Create the mapping database in memory\r
117 successfully\r
118\r
119**/
120EFI_STATUS
121EFIAPI
122InitOverridesMapping (
123 OUT LIST_ENTRY *MappingDataBase
124 );
125
126/**\r
127 Save the memory mapping database into NV environment variable(s)\r
128\r
129 @param MappingDataBase Mapping database list entry pointer\r
130\r
131 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r
132 @retval EFI_SUCCESS Save memory mapping database successfully\r
133\r
134**/
135EFI_STATUS
136EFIAPI
137SaveOverridesMapping (
138 IN LIST_ENTRY *MappingDataBase
139 );
140
141/**\r
142 Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.\r
143\r
144 @param This A pointer to the\r
145 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.\r
146 @param ControllerHandle The device handle of the controller to check if\r
147 a driver override exists.\r
148 @param DriverImageHandle On output, a pointer to the next driver handle.\r
149 Passing in a pointer to NULL, will return the\r
150 first driver handle for ControllerHandle.\r
151 @param MappingDataBase MappingDataBase - Mapping database list entry\r
152 pointer\r
153 @param CallerImageHandle The caller driver's image handle, for\r
154 UpdateFvFileDevicePath use.\r
155\r
156 @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not\r
157 a valid handle. Or DriverImagePath is not a\r
158 device path that was returned on a previous call\r
159 to GetDriverPath().\r
160 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not\r
161 found.\r
162 @retval EFI_UNSUPPORTED The operation is not supported.\r
163 @retval EFI_SUCCESS The driver override for ControllerHandle was\r
164 returned in DriverImagePath.\r
165\r
166**/
167EFI_STATUS
168EFIAPI
169GetDriverFromMapping (
170 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
171 IN EFI_HANDLE ControllerHandle,
172 IN OUT EFI_HANDLE * DriverImageHandle,
173 IN LIST_ENTRY * MappingDataBase,
174 IN EFI_HANDLE CallerImageHandle
175 );
176
177EFI_STATUS
178EFIAPI
179DeleteOverridesVariables (
180 VOID
181 );
182
183/**\r
184 Check mapping database whether already has the mapping info which\r
185 records the input Controller to input DriverImage.\r
186 If has, the controller's total override driver number and input DriverImage's order number is return.\r
187\r
188 @param ControllerDevicePath The controller device path need to add a\r
189 override driver image item\r
190 @param DriverImageDevicePath The driver image device path need to be insert\r
191 @param MappingDataBase Mapping database list entry pointer\r
192 @param DriverInfoNum the controller's total override driver number\r
193 @param DriverImageNO The inserted order number\r
194\r
195 @return EFI_INVALID_PARAMETER\r
196 @return EFI_NOT_FOUND\r
197 @return EFI_SUCCESS\r
198\r
199**/
200EFI_STATUS
201EFIAPI
202CheckMapping (
203 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
204 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
205 IN LIST_ENTRY * MappingDataBase,
206 OUT UINT32 *DriverInfoNum,
207 OUT UINT32 *DriverImageNO
208 );
209
210/**\r
211 Insert a driver image as a controller's override driver into the mapping database.\r
212 The driver image's order number is indicated by DriverImageNO.\r
213\r
214 @param ControllerDevicePath The controller device path need to add a\r
215 override driver image item\r
216 @param DriverImageDevicePath The driver image device path need to be insert\r
217 @param MappingDataBase Mapping database list entry pointer\r
218 @param DriverImageNO The inserted order number\r
219\r
220 @return EFI_INVALID_PARAMETER\r
221 @return EFI_ALREADY_STARTED\r
222 @return EFI_SUCCESS\r
223\r
224**/
225EFI_STATUS
226EFIAPI
227InsertDriverImage (
228 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
229 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
230 IN LIST_ENTRY *MappingDataBase,
231 IN UINT32 DriverImageNO
232 );
233
234/**\r
235 Delete a controller's override driver from the mapping database.\r
236\r
237 @param ControllerDevicePath The controller device path need to add a\r
238 override driver image item\r
239 @param DriverImageDevicePath The driver image device path need to be insert\r
240 @param MappingDataBase Mapping database list entry pointer\r
241 @param DriverImageNO The inserted order number\r
242\r
243 @return EFI_INVALID_PARAMETER\r
244 @return EFI_NOT_FOUND\r
245 @return EFI_SUCCESS\r
246\r
247**/
248EFI_STATUS
249EFIAPI
250DeleteDriverImage (
251 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
252 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
253 IN LIST_ENTRY *MappingDataBase
254 );
255
3012ce5c 256/**\r
257 Get the first Binding protocol which has the specific image handle\r
258\r
259 @param Image Image handle\r
260\r
261 @return Pointer into the Binding Protocol interface\r
262\r
263**/\r
264EFI_DRIVER_BINDING_PROTOCOL *\r
265EFIAPI\r
266GetBindingProtocolFromImageHandle (\r
267 IN EFI_HANDLE ImageHandle,\r
268 OUT EFI_HANDLE *BindingHandle\r
269 );
270
b290614d 271#endif