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