]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Universal / PlatformDriverOverride / PlatOverMngr / PlatOverMngr.h
1 /** @file
2
3 Copyright (c) 2007 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 PlatOverMngr.h
15
16 Abstract:
17
18 Function prototype for platform driver override manager driver
19
20 **/
21
22 #ifndef _PLAT_OVER_MNGR_H_
23 #define _PLAT_OVER_MNGR_H_
24
25 #include <PiDxe.h>
26
27 #include <Protocol/HiiConfigAccess.h>
28 #include <Protocol/HiiConfigRouting.h>
29 #include <Protocol/HiiDatabase.h>
30 #include <Protocol/LoadedImage.h>
31 #include <Protocol/FirmwareVolumeBlock.h>
32 #include <Protocol/FirmwareVolume2.h>
33 #include <Protocol/PciIo.h>
34 #include <Protocol/BusSpecificDriverOverride.h>
35 #include <Protocol/ComponentName2.h>
36 #include <Protocol/ComponentName.h>
37 #include <Protocol/DevicePathToText.h>
38
39 #include <Library/BaseLib.h>
40 #include <Library/DebugLib.h>
41 #include <Library/UefiLib.h>
42 #include <Library/UefiApplicationEntryPoint.h>
43 #include <Library/UefiBootServicesTableLib.h>
44 #include <Library/PlatDriOverLib.h>
45 #include <Library/IfrSupportLib.h>
46 #include <Library/ExtendedIfrSupportLib.h>
47 #include <Library/BaseMemoryLib.h>
48 #include <Library/MemoryAllocationLib.h>
49 #include <Library/HiiLib.h>
50 #include <Library/ExtendedHiiLib.h>
51 #include <Library/UefiRuntimeServicesTableLib.h>
52 #include <Library/DevicePathLib.h>
53
54 #define MIN_ALIGNMENT_SIZE 4
55 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
56
57
58 #define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')
59 #define EFI_CALLBACK_INFO_FROM_THIS(a) CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)
60 #define MAX_CHOICE_NUM 0x100
61 #define UPDATE_DATA_SIZE 0x1000
62
63
64 extern UINT8 VfrBin[];
65
66 extern UINT8 PlatOverMngrStrings[];
67
68 //
69 // Following definition is the same as in vfr file
70 //
71 #define PLAT_OVER_MNGR_GUID \
72 { \
73 0x8614567d, 0x35be, 0x4415, {0x8d, 0x88, 0xbd, 0x7d, 0xc, 0x9c, 0x70, 0xc0} \
74 }
75
76 typedef struct {
77 UINT8 DriSelection[100];
78 UINT8 DriOrder[100];
79 UINT8 PciDeviceFilter;
80 } PLAT_OVER_MNGR_DATA;
81
82 #define FORM_ID_DEVICE 0x1234
83 #define FORM_ID_DRIVER 0x1200
84 #define FORM_ID_ORDER 0x1500
85
86 #define KEY_VALUE_DEVICE_OFFSET 0x0100
87 #define KEY_VALUE_DEVICE_MAX 0x04ff
88
89 #define QUESTION_ID_OFFSET 0x0500
90
91 #define KEY_VALUE_DEVICE_REFRESH 0x1234
92 #define KEY_VALUE_DEVICE_FILTER 0x1235
93 #define KEY_VALUE_DEVICE_CLEAR 0x1236
94
95 #define KEY_VALUE_DRIVER_GOTO_PREVIOUS 0x1300
96 #define KEY_VALUE_DRIVER_GOTO_ORDER 0x1301
97
98 #define KEY_VALUE_ORDER_GOTO_PREVIOUS 0x2000
99 #define KEY_VALUE_ORDER_SAVE_AND_EXIT 0x1800
100
101 #define VARSTORE_ID_PLAT_OVER_MNGR 0x1000
102
103 //
104 // Question Id start from 1, so define an offset for it
105 //
106 #define VAR_OFFSET(Field) ((UINTN) &(((PLAT_OVER_MNGR_DATA *) 0)->Field))
107
108 #define DRIVER_SELECTION_VAR_OFFSET (VAR_OFFSET (DriSelection))
109 #define DRIVER_ORDER_VAR_OFFSET (VAR_OFFSET (DriOrder))
110
111 #define DRIVER_SELECTION_QUESTION_ID (VAR_OFFSET (DriSelection) + QUESTION_ID_OFFSET)
112 #define DRIVER_ORDER_QUESTION_ID (VAR_OFFSET (DriOrder) + QUESTION_ID_OFFSET)
113
114 typedef struct {
115 UINTN Signature;
116
117 EFI_HANDLE DriverHandle;
118 EFI_HII_HANDLE RegisteredHandle;
119 PLAT_OVER_MNGR_DATA FakeNvData;
120
121 EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
122
123 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
124 } EFI_CALLBACK_INFO;
125
126 typedef struct {
127 EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
128 EFI_HANDLE DriverImageHandle;
129 EFI_HANDLE ControllerHandle;
130 EFI_HANDLE ChildControllerHandle;
131 //
132 // To avoid created string leak in Hii database, use this token to reuse every token created by the driver
133 //
134 EFI_STRING_ID DescriptionToken;
135 } CFG_PROTOCOL_INVOKER_CHOICE;
136
137 /**
138 This function allows a caller to extract the current configuration for one
139 or more named elements from the target driver.
140
141 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
142 @param Request A null-terminated Unicode string in <ConfigRequest> format.
143 @param Progress On return, points to a character in the Request string.
144 Points to the string's null terminator if request was successful.
145 Points to the most recent '&' before the first failing name/value
146 pair (or the beginning of the string if the failure is in the
147 first name/value pair) if the request was not successful.
148 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
149 has all values filled in for the names in the Request string.
150 String to be allocated by the called function.
151
152 @retval EFI_SUCCESS The Results is filled with the requested values.
153 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
154 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
155 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
156
157 **/
158 EFI_STATUS
159 EFIAPI
160 PlatOverMngrExtractConfig (
161 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
162 IN CONST EFI_STRING Request,
163 OUT EFI_STRING *Progress,
164 OUT EFI_STRING *Results
165 );
166
167 /**
168 This function processes the results of changes in configuration.
169
170 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
171 @param Configuration A null-terminated Unicode string in <ConfigRequest> format.
172 @param Progress A pointer to a string filled in with the offset of the most
173 recent '&' before the first failing name/value pair (or the
174 beginning of the string if the failure is in the first
175 name/value pair) or the terminating NULL if all was successful.
176
177 @retval EFI_SUCCESS The Results is processed successfully.
178 @retval EFI_INVALID_PARAMETER Configuration is NULL.
179 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
180
181 **/
182 EFI_STATUS
183 EFIAPI
184 PlatOverMngrRouteConfig (
185 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
186 IN CONST EFI_STRING Configuration,
187 OUT EFI_STRING *Progress
188 );
189
190 /**
191 This is the function that is called to provide results data to the driver. This data
192 consists of a unique key which is used to identify what data is either being passed back
193 or being asked for.
194
195 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
196 @param Action A null-terminated Unicode string in <ConfigRequest> format.
197 @param KeyValue A unique Goto OpCode callback value which record user's selection.
198 0x100 <= KeyValue <0x500 : user select a controller item in the first page;
199 KeyValue == 0x1234 : user select 'Refresh' in first page, or user select 'Go to Previous Menu' in second page
200 KeyValue == 0x1235 : user select 'Pci device filter' in first page
201 KeyValue == 0x1500 : user select 'order ... priority' item in second page
202 KeyValue == 0x1800 : user select 'commint changes' in third page
203 KeyValue == 0x2000 : user select 'Go to Previous Menu' in third page
204 @param Type The type of value for the question.
205 @param Value A pointer to the data being sent to the original exporting driver.
206 @param ActionRequest On return, points to the action requested by the callback function.
207
208 @retval EFI_SUCCESS Always returned.
209
210 **/
211 EFI_STATUS
212 EFIAPI
213 PlatOverMngrCallback (
214 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
215 IN EFI_BROWSER_ACTION Action,
216 IN EFI_QUESTION_ID KeyValue,
217 IN UINT8 Type,
218 IN EFI_IFR_TYPE_VALUE *Value,
219 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
220 );
221
222 /**
223 Get the image name
224
225 @param Image Image to search.
226
227 @retval !NULL Pointer into the image name if the image name is found,
228 @retval NULL Pointer to NULL if the image name is not found.
229
230 **/
231 CHAR16 *
232 GetImageName (
233 IN EFI_LOADED_IMAGE_PROTOCOL *Image
234 );
235
236 /**
237 Get the description string by device path.
238
239 @param DevPath The input device path.
240
241 @retval !NULL The description string retured.
242 @retval NULL The description string cannot be found.
243
244 **/
245 CHAR16 *
246 DevicePathToStr (
247 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
248 );
249
250 #endif