]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/PlatDriOverLib.h
Port PlatformDriOverrideDxe into R9.
[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>
27#include <Library/BaseLib.h>
28
29#include <VariableFormat.h>
30
31/**\r
32 Install the Platform Driver Override Protocol, and ensure there is only one Platform Driver Override Protocol\r
33 in the system.\r
34\r
35 @param gPlatformDriverOverride PlatformDriverOverride protocol interface which\r
36 needs to be installed\r
37\r
38 @retval EFI_ALREADY_STARTED There has been a Platform Driver Override\r
39 Protocol in the system, cannot install it again.\r
40 @retval Other Returned by InstallProtocolInterface\r
41\r
42**/
43EFI_STATUS
44EFIAPI
45InstallPlatformDriverOverrideProtocol (
46 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *gPlatformDriverOverride
47 );
48
49/**\r
50 Free all the mapping database memory resource and initialize the mapping list entry\r
51\r
52 @param MappingDataBase Mapping database list entry pointer\r
53\r
54 @retval EFI_INVALID_PARAMETER mapping database list entry is NULL\r
55 @retval EFI_SUCCESS Free success\r
56\r
57**/
58EFI_STATUS
59EFIAPI
60FreeMappingDatabase (
61 IN OUT LIST_ENTRY *MappingDataBase
62 );
63
64/**\r
65 Read the environment variable(s) that contain the override mappings from Controller Device Path to\r
66 a set of Driver Device Paths, and create the mapping database in memory with those variable info.\r
67 VariableLayout{\r
68 //\r
69 // NotEnd indicate whether the variable is the last one, and has no subsequent variable need to load.\r
70 // Each variable has MaximumVariableSize limitation, so we maybe need multi variables to store\r
71 // large mapping infos.\r
72 // The variable(s) name rule is PlatDriOver, PlatDriOver1, PlatDriOver2, ....\r
73 //\r
74 UINT32 NotEnd;\r
75 //\r
76 // The entry which contains the mapping that Controller Device Path to a set of Driver Device Paths\r
77 // There are often multi mapping entries in a variable.\r
78 //\r
79 UINT32 SIGNATURE; //EFI_SIGNATURE_32('p','d','o','i')\r
80 UINT32 DriverNum;\r
81 EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];\r
82 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
83 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
84 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
85 ......\r
86 UINT32 SIGNATURE;\r
87 UINT32 DriverNum;\r
88 EFI_DEVICE_PATH_PROTOCOL ControllerDevicePath[];\r
89 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
90 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
91 EFI_DEVICE_PATH_PROTOCOL DriverDevicePath[];\r
92 ......\r
93 }\r
94 typedef struct _PLATFORM_OVERRIDE_ITEM{\r
95 UINTN Signature; //EFI_SIGNATURE_32('p','d','o','i')\r
96 LIST_ENTRY Link;\r
97 UINT32 DriverInfoNum;\r
98 EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;\r
99 LIST_ENTRY DriverInfoList; //DRIVER_IMAGE_INFO List\r
100 } PLATFORM_OVERRIDE_ITEM;\r
101 typedef struct _DRIVER_IMAGE_INFO{\r
102 UINTN Signature; //EFI_SIGNATURE_32('p','d','i','i')\r
103 LIST_ENTRY Link;\r
104 EFI_HANDLE ImageHandle;\r
105 EFI_DEVICE_PATH_PROTOCOL *DriverImagePath;\r
106 BOOLEAN UnLoadable;\r
107 BOOLEAN UnStartable;\r
108 } DRIVER_IMAGE_INFO;\r
109\r
110 @param MappingDataBase Mapping database list entry pointer\r
111\r
112 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r
113 @retval EFI_NOT_FOUND Cannot find the 'PlatDriOver' NV variable\r
114 @retval EFI_VOLUME_CORRUPTED The found NV variable is corrupted\r
115 @retval EFI_SUCCESS Create the mapping database in memory\r
116 successfully\r
117\r
118**/
119EFI_STATUS
120EFIAPI
121InitOverridesMapping (
122 OUT LIST_ENTRY *MappingDataBase
123 );
124
125/**\r
126 Save the memory mapping database into NV environment variable(s)\r
127\r
128 @param MappingDataBase Mapping database list entry pointer\r
129\r
130 @retval EFI_INVALID_PARAMETER MappingDataBase pointer is null\r
131 @retval EFI_SUCCESS Save memory mapping database successfully\r
132\r
133**/
134EFI_STATUS
135EFIAPI
136SaveOverridesMapping (
137 IN LIST_ENTRY *MappingDataBase
138 );
139
140/**\r
141 Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.\r
142\r
143 @param This A pointer to the\r
144 EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL instance.\r
145 @param ControllerHandle The device handle of the controller to check if\r
146 a driver override exists.\r
147 @param DriverImageHandle On output, a pointer to the next driver handle.\r
148 Passing in a pointer to NULL, will return the\r
149 first driver handle for ControllerHandle.\r
150 @param MappingDataBase MappingDataBase - Mapping database list entry\r
151 pointer\r
152 @param CallerImageHandle The caller driver's image handle, for\r
153 UpdateFvFileDevicePath use.\r
154\r
155 @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not\r
156 a valid handle. Or DriverImagePath is not a\r
157 device path that was returned on a previous call\r
158 to GetDriverPath().\r
159 @retval EFI_NOT_FOUND A driver override for ControllerHandle was not\r
160 found.\r
161 @retval EFI_UNSUPPORTED The operation is not supported.\r
162 @retval EFI_SUCCESS The driver override for ControllerHandle was\r
163 returned in DriverImagePath.\r
164\r
165**/
166EFI_STATUS
167EFIAPI
168GetDriverFromMapping (
169 IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
170 IN EFI_HANDLE ControllerHandle,
171 IN OUT EFI_HANDLE * DriverImageHandle,
172 IN LIST_ENTRY * MappingDataBase,
173 IN EFI_HANDLE CallerImageHandle
174 );
175
176EFI_STATUS
177EFIAPI
178DeleteOverridesVariables (
179 VOID
180 );
181
182/**\r
183 Check mapping database whether already has the mapping info which\r
184 records the input Controller to input DriverImage.\r
185 If has, the controller's total override driver number and input DriverImage's order number is return.\r
186\r
187 @param ControllerDevicePath The controller device path need to add a\r
188 override driver image item\r
189 @param DriverImageDevicePath The driver image device path need to be insert\r
190 @param MappingDataBase Mapping database list entry pointer\r
191 @param DriverInfoNum the controller's total override driver number\r
192 @param DriverImageNO The inserted order number\r
193\r
194 @return EFI_INVALID_PARAMETER\r
195 @return EFI_NOT_FOUND\r
196 @return EFI_SUCCESS\r
197\r
198**/
199EFI_STATUS
200EFIAPI
201CheckMapping (
202 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
203 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
204 IN LIST_ENTRY * MappingDataBase,
205 OUT UINT32 *DriverInfoNum,
206 OUT UINT32 *DriverImageNO
207 );
208
209/**\r
210 Insert a driver image as a controller's override driver into the mapping database.\r
211 The driver image's order number is indicated by DriverImageNO.\r
212\r
213 @param ControllerDevicePath The controller device path need to add a\r
214 override driver image item\r
215 @param DriverImageDevicePath The driver image device path need to be insert\r
216 @param MappingDataBase Mapping database list entry pointer\r
217 @param DriverImageNO The inserted order number\r
218\r
219 @return EFI_INVALID_PARAMETER\r
220 @return EFI_ALREADY_STARTED\r
221 @return EFI_SUCCESS\r
222\r
223**/
224EFI_STATUS
225EFIAPI
226InsertDriverImage (
227 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
228 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
229 IN LIST_ENTRY *MappingDataBase,
230 IN UINT32 DriverImageNO
231 );
232
233/**\r
234 Delete a controller's override driver from the mapping database.\r
235\r
236 @param ControllerDevicePath The controller device path need to add a\r
237 override driver image item\r
238 @param DriverImageDevicePath The driver image device path need to be insert\r
239 @param MappingDataBase Mapping database list entry pointer\r
240 @param DriverImageNO The inserted order number\r
241\r
242 @return EFI_INVALID_PARAMETER\r
243 @return EFI_NOT_FOUND\r
244 @return EFI_SUCCESS\r
245\r
246**/
247EFI_STATUS
248EFIAPI
249DeleteDriverImage (
250 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
251 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
252 IN LIST_ENTRY *MappingDataBase
253 );
254
255#endif