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