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