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