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