]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c
EmulatorPkg: Remove all trailing whitespace
[mirror_edk2.git] / EmulatorPkg / EmuBlockIoDxe / DriverConfiguration.c
CommitLineData
d59326d3 1/**@file\r
2\r
3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
d18d8a1d 4This 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
d59326d3 11\r
12Module Name:\r
13\r
14 DriverConfiguration.c\r
15\r
16Abstract:\r
17\r
18**/\r
19\r
20#include "EmuBlockIo.h"\r
21\r
22//\r
23// EFI Driver Configuration Functions\r
24//\r
25EFI_STATUS\r
26EFIAPI\r
27EmuBlockIoDriverConfigurationSetOptions (\r
28 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
29 IN EFI_HANDLE ControllerHandle,\r
30 IN EFI_HANDLE ChildHandle OPTIONAL,\r
31 IN CHAR8 *Language,\r
32 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
33 );\r
34\r
35EFI_STATUS\r
36EFIAPI\r
37EmuBlockIoDriverConfigurationOptionsValid (\r
38 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
39 IN EFI_HANDLE ControllerHandle,\r
40 IN EFI_HANDLE ChildHandle OPTIONAL\r
41 );\r
42\r
43EFI_STATUS\r
44EFIAPI\r
45EmuBlockIoDriverConfigurationForceDefaults (\r
46 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
47 IN EFI_HANDLE ControllerHandle,\r
48 IN EFI_HANDLE ChildHandle OPTIONAL,\r
49 IN UINT32 DefaultType,\r
50 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
51 );\r
52\r
53//\r
54// EFI Driver Configuration Protocol\r
55//\r
56EFI_DRIVER_CONFIGURATION_PROTOCOL gEmuBlockIoDriverConfiguration = {\r
57 EmuBlockIoDriverConfigurationSetOptions,\r
58 EmuBlockIoDriverConfigurationOptionsValid,\r
59 EmuBlockIoDriverConfigurationForceDefaults,\r
60 "eng"\r
61};\r
62\r
63/*++\r
64\r
65 Routine Description:\r
d18d8a1d 66 Allows the user to set controller specific options for a controller that a\r
d59326d3 67 driver is currently managing.\r
68\r
69 Arguments:\r
70 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
71 ControllerHandle - The handle of the controller to set options on.\r
72 ChildHandle - The handle of the child controller to set options on. This\r
d18d8a1d 73 is an optional parameter that may be NULL. It will be NULL\r
74 for device drivers, and for a bus drivers that wish to set\r
75 options for the bus controller. It will not be NULL for a\r
76 bus driver that wishes to set options for one of its child\r
d59326d3 77 controllers.\r
78 Language - A pointer to a three character ISO 639-2 language identifier.\r
d18d8a1d 79 This is the language of the user interface that should be\r
80 presented to the user, and it must match one of the languages\r
81 specified in SupportedLanguages. The number of languages\r
d59326d3 82 supported by a driver is up to the driver writer.\r
d18d8a1d 83 ActionRequired - A pointer to the action that the calling agent is required\r
84 to perform when this function returns. See "Related\r
85 Definitions" for a list of the actions that the calling\r
86 agent is required to perform prior to accessing\r
d59326d3 87 ControllerHandle again.\r
88\r
89 Returns:\r
d18d8a1d 90 EFI_SUCCESS - The driver specified by This successfully set the\r
91 configuration options for the controller specified\r
d59326d3 92 by ControllerHandle..\r
93 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
94 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
95 EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
d18d8a1d 96 EFI_UNSUPPORTED - The driver specified by This does not support setting\r
97 configuration options for the controller specified by\r
d59326d3 98 ControllerHandle and ChildHandle.\r
d18d8a1d 99 EFI_UNSUPPORTED - The driver specified by This does not support the\r
d59326d3 100 language specified by Language.\r
d18d8a1d 101 EFI_DEVICE_ERROR - A device error occurred while attempt to set the\r
102 configuration options for the controller specified\r
d59326d3 103 by ControllerHandle and ChildHandle.\r
d18d8a1d 104 EFI_OUT_RESOURCES - There are not enough resources available to set the\r
105 configuration options for the controller specified\r
d59326d3 106 by ControllerHandle and ChildHandle.\r
107\r
108--*/\r
109EFI_STATUS\r
110EFIAPI\r
111EmuBlockIoDriverConfigurationSetOptions (\r
112 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
113 IN EFI_HANDLE ControllerHandle,\r
114 IN EFI_HANDLE ChildHandle OPTIONAL,\r
115 IN CHAR8 *Language,\r
116 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
117 )\r
118{\r
119 EFI_STATUS Status;\r
120 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
121 CHAR8 *SupportedLanguage;\r
122\r
123 SupportedLanguage = This->SupportedLanguages;\r
124\r
125 Status = EFI_UNSUPPORTED;\r
126 while (*SupportedLanguage != 0) {\r
127 if (AsciiStrnCmp (Language, SupportedLanguage, 3) == 0) {\r
128 Status = EFI_SUCCESS;\r
129 }\r
130\r
131 SupportedLanguage += 3;\r
132 }\r
133\r
134 if (EFI_ERROR (Status)) {\r
135 return Status;\r
136 }\r
137\r
138 if (ActionRequired == NULL || ControllerHandle == NULL) {\r
139 return EFI_INVALID_PARAMETER;\r
140 }\r
141\r
142 if (ChildHandle != NULL) {\r
143 return EFI_UNSUPPORTED;\r
144 }\r
145\r
146 //\r
147 // Validate controller handle\r
148 //\r
149 Status = gBS->OpenProtocol (\r
150 ControllerHandle,\r
151 &gEmuIoThunkProtocolGuid,\r
152 (VOID **)&BlockIo,\r
153 gEmuBlockIoDriverBinding.DriverBindingHandle,\r
154 ControllerHandle,\r
155 EFI_OPEN_PROTOCOL_BY_DRIVER\r
156 );\r
157\r
158 if (!EFI_ERROR (Status)) {\r
159 gBS->CloseProtocol (\r
160 ControllerHandle,\r
161 &gEmuIoThunkProtocolGuid,\r
162 gEmuBlockIoDriverBinding.DriverBindingHandle,\r
163 ControllerHandle\r
164 );\r
165\r
166 return EFI_UNSUPPORTED;\r
167 }\r
168\r
169 if (Status == EFI_UNSUPPORTED) {\r
170 return Status;\r
171 } else if (Status != EFI_ALREADY_STARTED) {\r
172 return EFI_INVALID_PARAMETER;\r
173 }\r
174\r
175 *ActionRequired = EfiDriverConfigurationActionNone;\r
176 return EFI_SUCCESS;\r
177}\r
178\r
179/*++\r
180\r
181 Routine Description:\r
182 Tests to see if a controller's current configuration options are valid.\r
183\r
184 Arguments:\r
185 This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.\r
d18d8a1d 186 ControllerHandle - The handle of the controller to test if it's current\r
d59326d3 187 configuration options are valid.\r
188 ChildHandle - The handle of the child controller to test if it's current\r
d18d8a1d 189 configuration options are valid. This is an optional\r
190 parameter that may be NULL. It will be NULL for device\r
d59326d3 191 drivers. It will also be NULL for a bus drivers that wish\r
192 to test the configuration options for the bus controller.\r
d18d8a1d 193 It will not be NULL for a bus driver that wishes to test\r
d59326d3 194 configuration options for one of its child controllers.\r
195\r
196 Returns:\r
d18d8a1d 197 EFI_SUCCESS - The controller specified by ControllerHandle and\r
198 ChildHandle that is being managed by the driver\r
d59326d3 199 specified by This has a valid set of configuration\r
200 options.\r
201 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
202 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
d18d8a1d 203 EFI_UNSUPPORTED - The driver specified by This is not currently\r
204 managing the controller specified by ControllerHandle\r
d59326d3 205 and ChildHandle.\r
d18d8a1d 206 EFI_DEVICE_ERROR - The controller specified by ControllerHandle and\r
207 ChildHandle that is being managed by the driver\r
208 specified by This has an invalid set of configuration\r
d59326d3 209 options.\r
210\r
211--*/\r
212EFI_STATUS\r
213EFIAPI\r
214EmuBlockIoDriverConfigurationOptionsValid (\r
215 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
216 IN EFI_HANDLE ControllerHandle,\r
217 IN EFI_HANDLE ChildHandle OPTIONAL\r
218 )\r
219{\r
220 EFI_STATUS Status;\r
221 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
222\r
223 if (ChildHandle != NULL) {\r
224 return EFI_UNSUPPORTED;\r
225 }\r
226\r
227 if (ControllerHandle == NULL) {\r
228 return EFI_INVALID_PARAMETER;\r
229 }\r
230\r
231 //\r
232 // Validate controller handle\r
233 //\r
234 Status = gBS->OpenProtocol (\r
235 ControllerHandle,\r
236 &gEmuIoThunkProtocolGuid,\r
237 (VOID **)&BlockIo,\r
238 gEmuBlockIoDriverBinding.DriverBindingHandle,\r
239 ControllerHandle,\r
240 EFI_OPEN_PROTOCOL_BY_DRIVER\r
241 );\r
242\r
243 if (!EFI_ERROR (Status)) {\r
244 gBS->CloseProtocol (\r
245 ControllerHandle,\r
246 &gEmuIoThunkProtocolGuid,\r
247 gEmuBlockIoDriverBinding.DriverBindingHandle,\r
248 ControllerHandle\r
249 );\r
250\r
251 return EFI_UNSUPPORTED;\r
252 }\r
253\r
254 if (Status == EFI_UNSUPPORTED) {\r
255 return Status;\r
256 } else if (Status != EFI_ALREADY_STARTED) {\r
257 return EFI_INVALID_PARAMETER;\r
258 }\r
259\r
260 return EFI_SUCCESS;\r
261}\r
262\r
263/*++\r
264\r
265 Routine Description:\r
266 Forces a driver to set the default configuration options for a controller.\r
267\r
268 Arguments:\r
269 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
270 ControllerHandle - The handle of the controller to force default configuration options on.\r
271 ChildHandle - The handle of the child controller to force default configuration options on This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller. It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers.\r
272 DefaultType - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle. See Table 9-1 for legal values. A DefaultType of 0x00000000 must be supported by this protocol.\r
273 ActionRequired - A pointer to the action that the calling agent is required to perform when this function returns. See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again.\r
274\r
275 Returns:\r
276 EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
277 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
278 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
279 EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
280 EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
281 EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.\r
282 EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
283 EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
284\r
285--*/\r
286EFI_STATUS\r
287EFIAPI\r
288EmuBlockIoDriverConfigurationForceDefaults (\r
289 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
290 IN EFI_HANDLE ControllerHandle,\r
291 IN EFI_HANDLE ChildHandle OPTIONAL,\r
292 IN UINT32 DefaultType,\r
293 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
294 )\r
295{\r
296 EFI_STATUS Status;\r
297 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
298\r
299 if (ChildHandle != NULL) {\r
300 return EFI_UNSUPPORTED;\r
301 }\r
302\r
303 if (ActionRequired == NULL || ControllerHandle == NULL) {\r
304 return EFI_INVALID_PARAMETER;\r
305 }\r
306\r
307 //\r
308 // Validate controller handle\r
309 //\r
310 Status = gBS->OpenProtocol (\r
311 ControllerHandle,\r
312 &gEmuIoThunkProtocolGuid,\r
313 (VOID **)&BlockIo,\r
314 gEmuBlockIoDriverBinding.DriverBindingHandle,\r
315 ControllerHandle,\r
316 EFI_OPEN_PROTOCOL_BY_DRIVER\r
317 );\r
318\r
319 if (!EFI_ERROR (Status)) {\r
320 gBS->CloseProtocol (\r
321 ControllerHandle,\r
322 &gEmuIoThunkProtocolGuid,\r
323 gEmuBlockIoDriverBinding.DriverBindingHandle,\r
324 ControllerHandle\r
325 );\r
326\r
327 return EFI_UNSUPPORTED;\r
328 }\r
329\r
330 if (Status == EFI_UNSUPPORTED) {\r
331 return Status;\r
332 } else if (Status != EFI_ALREADY_STARTED) {\r
333 return EFI_INVALID_PARAMETER;\r
334 }\r
335\r
336 *ActionRequired = EfiDriverConfigurationActionNone;\r
337 return EFI_SUCCESS;\r
338}\r