]> git.proxmox.com Git - mirror_edk2.git/blame - EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/DriverConfiguration.c
Obsoleted by new schema and new build tools.
[mirror_edk2.git] / EdkNt32Pkg / Dxe / WinNtThunk / Bus / BlockIo / 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
20#include "WinNtBlockIo.h"\r
21\r
22//\r
23// EFI Driver Configuration Functions\r
24//\r
25EFI_STATUS\r
26EFIAPI\r
27WinNtBlockIoDriverConfigurationSetOptions (\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
37WinNtBlockIoDriverConfigurationOptionsValid (\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
45WinNtBlockIoDriverConfigurationForceDefaults (\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 gWinNtBlockIoDriverConfiguration = {\r
57 WinNtBlockIoDriverConfigurationSetOptions,\r
58 WinNtBlockIoDriverConfigurationOptionsValid,\r
59 WinNtBlockIoDriverConfigurationForceDefaults,\r
60 LANGUAGESUPPORTED\r
61};\r
62\r
63EFI_STATUS\r
64EFIAPI\r
65WinNtBlockIoDriverConfigurationSetOptions (\r
66 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
67 IN EFI_HANDLE ControllerHandle,\r
68 IN EFI_HANDLE ChildHandle OPTIONAL,\r
69 IN CHAR8 *Language,\r
70 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
71 )\r
72/*++\r
73\r
74 Routine Description:\r
75 Allows the user to set controller specific options for a controller that a\r
76 driver is currently managing.\r
77\r
78 Arguments:\r
79 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
80 ControllerHandle - The handle of the controller to set options on.\r
81 ChildHandle - The handle of the child controller to set options on. This\r
82 is an optional parameter that may be NULL. It will be NULL\r
83 for device drivers, and for a bus drivers that wish to set\r
84 options for the bus controller. It will not be NULL for a\r
85 bus driver that wishes to set options for one of its child\r
86 controllers.\r
87 Language - A pointer to a three character ISO 639-2 language identifier.\r
88 This is the language of the user interface that should be\r
89 presented to the user, and it must match one of the languages\r
90 specified in SupportedLanguages. The number of languages\r
91 supported by a driver is up to the driver writer.\r
92 ActionRequired - A pointer to the action that the calling agent is required\r
93 to perform when this function returns. See "Related\r
94 Definitions" for a list of the actions that the calling\r
95 agent is required to perform prior to accessing\r
96 ControllerHandle again.\r
97\r
98 Returns:\r
99 EFI_SUCCESS - The driver specified by This successfully set the\r
100 configuration options for the controller specified\r
101 by ControllerHandle..\r
102 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
103 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
104 EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
105 EFI_UNSUPPORTED - The driver specified by This does not support setting\r
106 configuration options for the controller specified by\r
107 ControllerHandle and ChildHandle.\r
108 EFI_UNSUPPORTED - The driver specified by This does not support the\r
109 language specified by Language.\r
110 EFI_DEVICE_ERROR - A device error occurred while attempt to set the\r
111 configuration options for the controller specified\r
112 by ControllerHandle and ChildHandle.\r
113 EFI_OUT_RESOURCES - There are not enough resources available to set the\r
114 configuration options for the controller specified\r
115 by ControllerHandle and ChildHandle.\r
116\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 &gEfiWinNtIoProtocolGuid,\r
152 &BlockIo,\r
153 gWinNtBlockIoDriverBinding.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 &gEfiWinNtIoProtocolGuid,\r
162 gWinNtBlockIoDriverBinding.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
179EFI_STATUS\r
180EFIAPI\r
181WinNtBlockIoDriverConfigurationOptionsValid (\r
182 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
183 IN EFI_HANDLE ControllerHandle,\r
184 IN EFI_HANDLE ChildHandle OPTIONAL\r
185 )\r
186/*++\r
187\r
188 Routine Description:\r
189 Tests to see if a controller's current configuration options are valid.\r
190\r
191 Arguments:\r
192 This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.\r
193 ControllerHandle - The handle of the controller to test if it's current\r
194 configuration options are valid.\r
195 ChildHandle - The handle of the child controller to test if it's current\r
196 configuration options are valid. This is an optional\r
197 parameter that may be NULL. It will be NULL for device\r
198 drivers. It will also be NULL for a bus drivers that wish\r
199 to test the configuration options for the bus controller.\r
200 It will not be NULL for a bus driver that wishes to test\r
201 configuration options for one of its child controllers.\r
202\r
203 Returns:\r
204 EFI_SUCCESS - The controller specified by ControllerHandle and\r
205 ChildHandle that is being managed by the driver\r
206 specified by This has a valid set of configuration\r
207 options.\r
208 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
209 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
210 EFI_UNSUPPORTED - The driver specified by This is not currently\r
211 managing the controller specified by ControllerHandle\r
212 and ChildHandle.\r
213 EFI_DEVICE_ERROR - The controller specified by ControllerHandle and\r
214 ChildHandle that is being managed by the driver\r
215 specified by This has an invalid set of configuration\r
216 options.\r
217\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 &gEfiWinNtIoProtocolGuid,\r
237 &BlockIo,\r
238 gWinNtBlockIoDriverBinding.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 &gEfiWinNtIoProtocolGuid,\r
247 gWinNtBlockIoDriverBinding.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
263EFI_STATUS\r
264EFIAPI\r
265WinNtBlockIoDriverConfigurationForceDefaults (\r
266 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,\r
267 IN EFI_HANDLE ControllerHandle,\r
268 IN EFI_HANDLE ChildHandle OPTIONAL,\r
269 IN UINT32 DefaultType,\r
270 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired\r
271 )\r
272/*++\r
273\r
274 Routine Description:\r
275 Forces a driver to set the default configuration options for a controller.\r
276\r
277 Arguments:\r
278 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
279 ControllerHandle - The handle of the controller to force default configuration options on.\r
280 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
281 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
282 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
283\r
284 Returns:\r
285 EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
286 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
287 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
288 EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
289 EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
290 EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.\r
291 EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
292 EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
293\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 &gEfiWinNtIoProtocolGuid,\r
313 &BlockIo,\r
314 gWinNtBlockIoDriverBinding.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 &gEfiWinNtIoProtocolGuid,\r
323 gWinNtBlockIoDriverBinding.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