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