]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Bus/Pci/IdeBus/Dxe/DriverConfiguration.c
Fix capitalization.
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / IdeBus / Dxe / DriverConfiguration.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 DriverConfiguration.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
f0ec738d 20#include "idebus.h"\r
878ddf1f 21\r
22CHAR16 *OptionString[4] = {\r
23 L"Enable Primary Master (Y/N)? -->",\r
24 L"Enable Primary Slave (Y/N)? -->",\r
25 L"Enable Secondary Master (Y/N)? -->",\r
26 L"Enable Secondary Slave (Y/N)? -->"\r
27};\r
28//\r
29// EFI Driver Configuration Functions\r
30//\r
31EFI_STATUS\r
32IDEBusDriverConfigurationSetOptions (\r
33 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
34 IN EFI_HANDLE ControllerHandle,\r
35 IN EFI_HANDLE ChildHandle OPTIONAL,\r
36 IN CHAR8 *Language,\r
37 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
38 );\r
39\r
40EFI_STATUS\r
41IDEBusDriverConfigurationOptionsValid (\r
42 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
43 IN EFI_HANDLE ControllerHandle,\r
44 IN EFI_HANDLE ChildHandle OPTIONAL\r
45 );\r
46\r
47EFI_STATUS\r
48IDEBusDriverConfigurationForceDefaults (\r
49 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
50 IN EFI_HANDLE ControllerHandle,\r
51 IN EFI_HANDLE ChildHandle OPTIONAL,\r
52 IN UINT32 DefaultType,\r
53 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
54 );\r
55\r
56//\r
57// EFI Driver Configuration Protocol\r
58//\r
59EFI_DRIVER_CONFIGURATION_PROTOCOL gIDEBusDriverConfiguration = {\r
60 IDEBusDriverConfigurationSetOptions,\r
61 IDEBusDriverConfigurationOptionsValid,\r
62 IDEBusDriverConfigurationForceDefaults,\r
63 "eng"\r
64};\r
65\r
66EFI_STATUS\r
67GetResponse (\r
68 VOID\r
69 )\r
70/*++\r
71\r
72Routine Description:\r
73\r
74 TODO: Add function description\r
75\r
76Arguments:\r
77\r
78 None\r
79\r
80Returns:\r
81\r
82 EFI_ABORTED - TODO: Add description for return value\r
83 EFI_SUCCESS - TODO: Add description for return value\r
84 EFI_NOT_FOUND - TODO: Add description for return value\r
85\r
86--*/\r
87{\r
88 EFI_STATUS Status;\r
89 EFI_INPUT_KEY Key;\r
90\r
91 while (TRUE) {\r
92 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
93 if (!EFI_ERROR (Status)) {\r
94 if (Key.ScanCode == SCAN_ESC) {\r
95 return EFI_ABORTED;\r
96 }\r
97\r
98 switch (Key.UnicodeChar) {\r
99\r
100 //\r
101 // fall through\r
102 //\r
103 case L'y':\r
104 case L'Y':\r
105 gST->ConOut->OutputString (gST->ConOut, L"Y\n");\r
106 return EFI_SUCCESS;\r
107\r
108 //\r
109 // fall through\r
110 //\r
111 case L'n':\r
112 case L'N':\r
113 gST->ConOut->OutputString (gST->ConOut, L"N\n");\r
114 return EFI_NOT_FOUND;\r
115 }\r
116\r
117 }\r
118 }\r
119}\r
120\r
121EFI_STATUS\r
122IDEBusDriverConfigurationSetOptions (\r
123 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
124 IN EFI_HANDLE ControllerHandle,\r
125 IN EFI_HANDLE ChildHandle OPTIONAL,\r
126 IN CHAR8 *Language,\r
127 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
128 )\r
129/*++\r
130\r
131 Routine Description:\r
132 Allows the user to set controller specific options for a controller that a \r
133 driver is currently managing.\r
134\r
135 Arguments:\r
136 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL \r
137 instance.\r
138 ControllerHandle - The handle of the controller to set options on.\r
139 ChildHandle - The handle of the child controller to set options on. \r
140 This is an optional parameter that may be NULL. \r
141 It will be NULL for device drivers, and for a bus drivers\r
142 that wish to set options for the bus controller. \r
143 It will not be NULL for a bus driver that wishes to set \r
144 options for one of its child controllers.\r
145 Language - A pointer to a three character ISO 639-2 language \r
146 identifier. This is the language of the user interface \r
147 that should be presented to the user, and it must match \r
148 one of the languages specified in SupportedLanguages. \r
149 The number of languages supported by a driver is up to \r
150 the driver writer.\r
151 ActionRequired - A pointer to the action that the calling agent is \r
152 required to perform when this function returns. \r
153 See "Related Definitions" for a list of the actions that\r
154 the calling agent is required to perform prior to \r
155 accessing ControllerHandle again.\r
156\r
157 Returns:\r
158 EFI_SUCCESS - The driver specified by This successfully set the \r
159 configuration options for the controller specified \r
160 by ControllerHandle..\r
161 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
162 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a \r
163 valid EFI_HANDLE.\r
164 EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
165 EFI_UNSUPPORTED - The driver specified by This does not support \r
166 setting configuration options for the controller \r
167 specified by ControllerHandle and ChildHandle.\r
168 EFI_UNSUPPORTED - The driver specified by This does not support the \r
169 language specified by Language.\r
170 EFI_DEVICE_ERROR - A device error occurred while attempt to set the \r
171 configuration options for the controller specified \r
172 by ControllerHandle and ChildHandle.\r
173 EFI_OUT_RESOURCES - There are not enough resources available to set the \r
174 configuration options for the controller specified \r
175 by ControllerHandle and ChildHandle.\r
176\r
177--*/\r
178{\r
179 EFI_STATUS Status;\r
180 UINT8 Value;\r
181 UINT8 NewValue;\r
182 UINTN DataSize;\r
183 UINTN Index;\r
184 UINT32 Attributes;\r
185\r
186 if (ChildHandle != NULL) {\r
187 return EFI_UNSUPPORTED;\r
188 }\r
189\r
190 *ActionRequired = EfiDriverConfigurationActionNone;\r
191\r
192 DataSize = sizeof (Value);\r
193 Status = gRT->GetVariable (\r
194 L"Configuration",\r
195 &gEfiCallerIdGuid,\r
196 &Attributes,\r
197 &DataSize,\r
198 &Value\r
199 );\r
200\r
201 gST->ConOut->OutputString (gST->ConOut, L"IDE Bus Driver Configuration\n");\r
202 gST->ConOut->OutputString (gST->ConOut, L"===============================\n");\r
203\r
204 NewValue = 0;\r
205 for (Index = 0; Index < 4; Index++) {\r
206 gST->ConOut->OutputString (gST->ConOut, OptionString[Index]);\r
207\r
208 Status = GetResponse ();\r
209 if (Status == EFI_ABORTED) {\r
210 return EFI_SUCCESS;\r
211 }\r
212\r
213 if (!EFI_ERROR (Status)) {\r
214 NewValue |= (UINT8) (1 << Index);\r
215 }\r
216 }\r
217\r
218 if (EFI_ERROR (Status) || (NewValue != Value)) {\r
219 gRT->SetVariable (\r
220 L"Configuration",\r
221 &gEfiCallerIdGuid,\r
222 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
223 sizeof (NewValue),\r
224 &NewValue\r
225 );\r
226\r
227 *ActionRequired = EfiDriverConfigurationActionRestartController;\r
228 } else {\r
229 *ActionRequired = EfiDriverConfigurationActionNone;\r
230 }\r
231\r
232 return EFI_SUCCESS;\r
233}\r
234\r
235EFI_STATUS\r
236IDEBusDriverConfigurationOptionsValid (\r
237 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
238 IN EFI_HANDLE ControllerHandle,\r
239 IN EFI_HANDLE ChildHandle OPTIONAL\r
240 )\r
241/*++\r
242\r
243 Routine Description:\r
244 Tests to see if a controller's current configuration options are valid.\r
245\r
246 Arguments:\r
247 This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL \r
248 instance.\r
249 ControllerHandle - The handle of the controller to test if it's current \r
250 configuration options are valid.\r
251 ChildHandle - The handle of the child controller to test if it's \r
252 current\r
253 configuration options are valid. This is an optional \r
254 parameter that may be NULL. It will be NULL for device \r
255 drivers. It will also be NULL for a bus drivers that \r
256 wish to test the configuration options for the bus \r
257 controller. It will not be NULL for a bus driver that \r
258 wishes to test configuration options for one of \r
259 its child controllers.\r
260\r
261 Returns:\r
262 EFI_SUCCESS - The controller specified by ControllerHandle and \r
263 ChildHandle that is being managed by the driver \r
264 specified by This has a valid set of configuration\r
265 options.\r
266 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
267 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
268 EFI_HANDLE.\r
269 EFI_UNSUPPORTED - The driver specified by This is not currently \r
270 managing the controller specified by \r
271 ControllerHandle and ChildHandle.\r
272 EFI_DEVICE_ERROR - The controller specified by ControllerHandle and \r
273 ChildHandle that is being managed by the driver \r
274 specified by This has an invalid set of \r
275 configuration options.\r
276\r
277--*/\r
278{\r
279 EFI_STATUS Status;\r
280 UINT8 Value;\r
281 UINTN DataSize;\r
282 UINT32 Attributes;\r
283\r
284 if (ChildHandle != NULL) {\r
285 return EFI_UNSUPPORTED;\r
286 }\r
287\r
288 DataSize = sizeof (Value);\r
289 Status = gRT->GetVariable (\r
290 L"Configuration",\r
291 &gEfiCallerIdGuid,\r
292 &Attributes,\r
293 &DataSize,\r
294 &Value\r
295 );\r
296 if (EFI_ERROR (Status) || Value > 0x0f) {\r
297 return EFI_DEVICE_ERROR;\r
298 }\r
299\r
300 return EFI_SUCCESS;\r
301}\r
302\r
303EFI_STATUS\r
304IDEBusDriverConfigurationForceDefaults (\r
305 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
306 IN EFI_HANDLE ControllerHandle,\r
307 IN EFI_HANDLE ChildHandle OPTIONAL,\r
308 IN UINT32 DefaultType,\r
309 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
310 )\r
311/*++\r
312\r
313 Routine Description:\r
314 Forces a driver to set the default configuration options for a controller.\r
315\r
316 Arguments:\r
317 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL \r
318 instance.\r
319 ControllerHandle - The handle of the controller to force default \r
320 configuration options on.\r
321 ChildHandle - The handle of the child controller to force default \r
322 configuration options on This is an optional parameter \r
323 that may be NULL. It will be NULL for device drivers. \r
324 It will also be NULL for a bus drivers that wish to \r
325 force default configuration options for the bus \r
326 controller. It will not be NULL for a bus driver that \r
327 wishes to force default configuration options for one \r
328 of its child controllers.\r
329 DefaultType - The type of default configuration options to force on \r
330 the controller specified by ControllerHandle and \r
331 ChildHandle. See Table 9-1 for legal values. \r
332 A DefaultType of 0x00000000 must be supported \r
333 by this protocol.\r
334 ActionRequired - A pointer to the action that the calling agent \r
335 is required to perform when this function returns. \r
336 \r
337\r
338 Returns:\r
339 EFI_SUCCESS - The driver specified by This successfully forced \r
340 the default configuration options on the \r
341 controller specified by ControllerHandle and \r
342 ChildHandle.\r
343 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
344 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a \r
345 valid EFI_HANDLE.\r
346 EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
347 EFI_UNSUPPORTED - The driver specified by This does not support \r
348 forcing the default configuration options on \r
349 the controller specified by ControllerHandle \r
350 and ChildHandle.\r
351 EFI_UNSUPPORTED - The driver specified by This does not support \r
352 the configuration type specified by DefaultType.\r
353 EFI_DEVICE_ERROR - A device error occurred while attempt to force \r
354 the default configuration options on the controller \r
355 specified by ControllerHandle and ChildHandle.\r
356 EFI_OUT_RESOURCES - There are not enough resources available to force \r
357 the default configuration options on the controller \r
358 specified by ControllerHandle and ChildHandle.\r
359\r
360--*/\r
361{\r
362 UINT8 Value;\r
363\r
364 if (ChildHandle != NULL) {\r
365 return EFI_UNSUPPORTED;\r
366 }\r
367\r
368 Value = 0x0f;\r
369 gRT->SetVariable (\r
370 L"Configuration",\r
371 &gEfiCallerIdGuid,\r
372 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
373 sizeof (Value),\r
374 &Value\r
375 );\r
376 *ActionRequired = EfiDriverConfigurationActionRestartController;\r
377 return EFI_SUCCESS;\r
378}\r