3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 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 "EmuBlockIo.h"
23 // EFI Driver Configuration Functions
27 EmuBlockIoDriverConfigurationSetOptions (
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 EmuBlockIoDriverConfigurationOptionsValid (
38 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
39 IN EFI_HANDLE ControllerHandle
,
40 IN EFI_HANDLE ChildHandle OPTIONAL
45 EmuBlockIoDriverConfigurationForceDefaults (
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 gEmuBlockIoDriverConfiguration
= {
57 EmuBlockIoDriverConfigurationSetOptions
,
58 EmuBlockIoDriverConfigurationOptionsValid
,
59 EmuBlockIoDriverConfigurationForceDefaults
,
66 Allows the user to set controller specific options for a controller that a
67 driver is currently managing.
70 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
71 ControllerHandle - The handle of the controller to set options on.
72 ChildHandle - The handle of the child controller to set options on. This
73 is an optional parameter that may be NULL. It will be NULL
74 for device drivers, and for a bus drivers that wish to set
75 options for the bus controller. It will not be NULL for a
76 bus driver that wishes to set options for one of its child
78 Language - A pointer to a three character ISO 639-2 language identifier.
79 This is the language of the user interface that should be
80 presented to the user, and it must match one of the languages
81 specified in SupportedLanguages. The number of languages
82 supported by a driver is up to the driver writer.
83 ActionRequired - A pointer to the action that the calling agent is required
84 to perform when this function returns. See "Related
85 Definitions" for a list of the actions that the calling
86 agent is required to perform prior to accessing
87 ControllerHandle again.
90 EFI_SUCCESS - The driver specified by This successfully set the
91 configuration options for the controller specified
93 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
94 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
95 EFI_INVALID_PARAMETER - ActionRequired is NULL.
96 EFI_UNSUPPORTED - The driver specified by This does not support setting
97 configuration options for the controller specified by
98 ControllerHandle and ChildHandle.
99 EFI_UNSUPPORTED - The driver specified by This does not support the
100 language specified by Language.
101 EFI_DEVICE_ERROR - A device error occurred while attempt to set the
102 configuration options for the controller specified
103 by ControllerHandle and ChildHandle.
104 EFI_OUT_RESOURCES - There are not enough resources available to set the
105 configuration options for the controller specified
106 by ControllerHandle and ChildHandle.
111 EmuBlockIoDriverConfigurationSetOptions (
112 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
113 IN EFI_HANDLE ControllerHandle
,
114 IN EFI_HANDLE ChildHandle OPTIONAL
,
116 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
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) == 0) {
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 &gEmuIoThunkProtocolGuid
,
153 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
155 EFI_OPEN_PROTOCOL_BY_DRIVER
158 if (!EFI_ERROR (Status
)) {
161 &gEmuIoThunkProtocolGuid
,
162 gEmuBlockIoDriverBinding
.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
;
182 Tests to see if a controller's current configuration options are valid.
185 This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
186 ControllerHandle - The handle of the controller to test if it's current
187 configuration options are valid.
188 ChildHandle - The handle of the child controller to test if it's current
189 configuration options are valid. This is an optional
190 parameter that may be NULL. It will be NULL for device
191 drivers. It will also be NULL for a bus drivers that wish
192 to test the configuration options for the bus controller.
193 It will not be NULL for a bus driver that wishes to test
194 configuration options for one of its child controllers.
197 EFI_SUCCESS - The controller specified by ControllerHandle and
198 ChildHandle that is being managed by the driver
199 specified by This has a valid set of configuration
201 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
202 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
203 EFI_UNSUPPORTED - The driver specified by This is not currently
204 managing the controller specified by ControllerHandle
206 EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
207 ChildHandle that is being managed by the driver
208 specified by This has an invalid set of configuration
214 EmuBlockIoDriverConfigurationOptionsValid (
215 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
216 IN EFI_HANDLE ControllerHandle
,
217 IN EFI_HANDLE ChildHandle OPTIONAL
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 &gEmuIoThunkProtocolGuid
,
238 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
240 EFI_OPEN_PROTOCOL_BY_DRIVER
243 if (!EFI_ERROR (Status
)) {
246 &gEmuIoThunkProtocolGuid
,
247 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
251 return EFI_UNSUPPORTED
;
254 if (Status
== EFI_UNSUPPORTED
) {
256 } else if (Status
!= EFI_ALREADY_STARTED
) {
257 return EFI_INVALID_PARAMETER
;
266 Forces a driver to set the default configuration options for a controller.
269 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
270 ControllerHandle - The handle of the controller to force default configuration options on.
271 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.
272 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.
273 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.
276 EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.
277 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
278 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
279 EFI_INVALID_PARAMETER - ActionRequired is NULL.
280 EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.
281 EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.
282 EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
283 EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
288 EmuBlockIoDriverConfigurationForceDefaults (
289 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
290 IN EFI_HANDLE ControllerHandle
,
291 IN EFI_HANDLE ChildHandle OPTIONAL
,
292 IN UINT32 DefaultType
,
293 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
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 &gEmuIoThunkProtocolGuid
,
314 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
316 EFI_OPEN_PROTOCOL_BY_DRIVER
319 if (!EFI_ERROR (Status
)) {
322 &gEmuIoThunkProtocolGuid
,
323 gEmuBlockIoDriverBinding
.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
;