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