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
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.
20 #include "UnixBlockIo.h"
23 // EFI Driver Configuration Functions
27 UnixBlockIoDriverConfigurationSetOptions (
28 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
29 IN EFI_HANDLE ControllerHandle
,
30 IN EFI_HANDLE ChildHandle OPTIONAL
,
32 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
37 UnixBlockIoDriverConfigurationOptionsValid (
38 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
39 IN EFI_HANDLE ControllerHandle
,
40 IN EFI_HANDLE ChildHandle OPTIONAL
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
54 // EFI Driver Configuration Protocol
56 EFI_DRIVER_CONFIGURATION_PROTOCOL gUnixBlockIoDriverConfiguration
= {
57 UnixBlockIoDriverConfigurationSetOptions
,
58 UnixBlockIoDriverConfigurationOptionsValid
,
59 UnixBlockIoDriverConfigurationForceDefaults
,
65 UnixBlockIoDriverConfigurationSetOptions (
66 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
67 IN EFI_HANDLE ControllerHandle
,
68 IN EFI_HANDLE ChildHandle OPTIONAL
,
70 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
75 Allows the user to set controller specific options for a controller that a
76 driver is currently managing.
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
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.
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.
120 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
121 CHAR8
*SupportedLanguage
;
123 SupportedLanguage
= This
->SupportedLanguages
;
125 Status
= EFI_UNSUPPORTED
;
126 while (*SupportedLanguage
!= 0) {
127 if (AsciiStrnCmp (Language
, SupportedLanguage
, 3)) {
128 Status
= EFI_SUCCESS
;
131 SupportedLanguage
+= 3;
134 if (EFI_ERROR (Status
)) {
138 if (ActionRequired
== NULL
|| ControllerHandle
== NULL
) {
139 return EFI_INVALID_PARAMETER
;
142 if (ChildHandle
!= NULL
) {
143 return EFI_UNSUPPORTED
;
147 // Validate controller handle
149 Status
= gBS
->OpenProtocol (
151 &gEfiUnixIoProtocolGuid
,
153 gUnixBlockIoDriverBinding
.DriverBindingHandle
,
155 EFI_OPEN_PROTOCOL_BY_DRIVER
158 if (!EFI_ERROR (Status
)) {
161 &gEfiUnixIoProtocolGuid
,
162 gUnixBlockIoDriverBinding
.DriverBindingHandle
,
166 return EFI_UNSUPPORTED
;
169 if (Status
== EFI_UNSUPPORTED
) {
171 } else if (Status
!= EFI_ALREADY_STARTED
) {
172 return EFI_INVALID_PARAMETER
;
175 *ActionRequired
= EfiDriverConfigurationActionNone
;
181 UnixBlockIoDriverConfigurationOptionsValid (
182 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
183 IN EFI_HANDLE ControllerHandle
,
184 IN EFI_HANDLE ChildHandle OPTIONAL
189 Tests to see if a controller's current configuration options are valid.
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.
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
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
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
221 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
223 if (ChildHandle
!= NULL
) {
224 return EFI_UNSUPPORTED
;
227 if (ControllerHandle
== NULL
) {
228 return EFI_INVALID_PARAMETER
;
232 // Validate controller handle
234 Status
= gBS
->OpenProtocol (
236 &gEfiUnixIoProtocolGuid
,
238 gUnixBlockIoDriverBinding
.DriverBindingHandle
,
240 EFI_OPEN_PROTOCOL_BY_DRIVER
243 if (!EFI_ERROR (Status
)) {
246 &gEfiUnixIoProtocolGuid
,
247 gUnixBlockIoDriverBinding
.DriverBindingHandle
,
251 return EFI_UNSUPPORTED
;
254 if (Status
== EFI_UNSUPPORTED
) {
256 } else if (Status
!= EFI_ALREADY_STARTED
) {
257 return EFI_INVALID_PARAMETER
;
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
275 Forces a driver to set the default configuration options for a controller.
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.
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.
297 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
299 if (ChildHandle
!= NULL
) {
300 return EFI_UNSUPPORTED
;
303 if (ActionRequired
== NULL
|| ControllerHandle
== NULL
) {
304 return EFI_INVALID_PARAMETER
;
308 // Validate controller handle
310 Status
= gBS
->OpenProtocol (
312 &gEfiUnixIoProtocolGuid
,
314 gUnixBlockIoDriverBinding
.DriverBindingHandle
,
316 EFI_OPEN_PROTOCOL_BY_DRIVER
319 if (!EFI_ERROR (Status
)) {
322 &gEfiUnixIoProtocolGuid
,
323 gUnixBlockIoDriverBinding
.DriverBindingHandle
,
327 return EFI_UNSUPPORTED
;
330 if (Status
== EFI_UNSUPPORTED
) {
332 } else if (Status
!= EFI_ALREADY_STARTED
) {
333 return EFI_INVALID_PARAMETER
;
336 *ActionRequired
= EfiDriverConfigurationActionNone
;