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