3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include "EmuBlockIo.h"
17 // EFI Driver Configuration Functions
21 EmuBlockIoDriverConfigurationSetOptions (
22 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
23 IN EFI_HANDLE ControllerHandle
,
24 IN EFI_HANDLE ChildHandle OPTIONAL
,
26 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
31 EmuBlockIoDriverConfigurationOptionsValid (
32 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
33 IN EFI_HANDLE ControllerHandle
,
34 IN EFI_HANDLE ChildHandle OPTIONAL
39 EmuBlockIoDriverConfigurationForceDefaults (
40 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
41 IN EFI_HANDLE ControllerHandle
,
42 IN EFI_HANDLE ChildHandle OPTIONAL
,
43 IN UINT32 DefaultType
,
44 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
48 // EFI Driver Configuration Protocol
50 EFI_DRIVER_CONFIGURATION_PROTOCOL gEmuBlockIoDriverConfiguration
= {
51 EmuBlockIoDriverConfigurationSetOptions
,
52 EmuBlockIoDriverConfigurationOptionsValid
,
53 EmuBlockIoDriverConfigurationForceDefaults
,
60 Allows the user to set controller specific options for a controller that a
61 driver is currently managing.
64 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
65 ControllerHandle - The handle of the controller to set options on.
66 ChildHandle - The handle of the child controller to set options on. This
67 is an optional parameter that may be NULL. It will be NULL
68 for device drivers, and for a bus drivers that wish to set
69 options for the bus controller. It will not be NULL for a
70 bus driver that wishes to set options for one of its child
72 Language - A pointer to a three character ISO 639-2 language identifier.
73 This is the language of the user interface that should be
74 presented to the user, and it must match one of the languages
75 specified in SupportedLanguages. The number of languages
76 supported by a driver is up to the driver writer.
77 ActionRequired - A pointer to the action that the calling agent is required
78 to perform when this function returns. See "Related
79 Definitions" for a list of the actions that the calling
80 agent is required to perform prior to accessing
81 ControllerHandle again.
84 EFI_SUCCESS - The driver specified by This successfully set the
85 configuration options for the controller specified
87 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
88 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
89 EFI_INVALID_PARAMETER - ActionRequired is NULL.
90 EFI_UNSUPPORTED - The driver specified by This does not support setting
91 configuration options for the controller specified by
92 ControllerHandle and ChildHandle.
93 EFI_UNSUPPORTED - The driver specified by This does not support the
94 language specified by Language.
95 EFI_DEVICE_ERROR - A device error occurred while attempt to set the
96 configuration options for the controller specified
97 by ControllerHandle and ChildHandle.
98 EFI_OUT_RESOURCES - There are not enough resources available to set the
99 configuration options for the controller specified
100 by ControllerHandle and ChildHandle.
105 EmuBlockIoDriverConfigurationSetOptions (
106 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
107 IN EFI_HANDLE ControllerHandle
,
108 IN EFI_HANDLE ChildHandle OPTIONAL
,
110 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
114 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
115 CHAR8
*SupportedLanguage
;
117 SupportedLanguage
= This
->SupportedLanguages
;
119 Status
= EFI_UNSUPPORTED
;
120 while (*SupportedLanguage
!= 0) {
121 if (AsciiStrnCmp (Language
, SupportedLanguage
, 3) == 0) {
122 Status
= EFI_SUCCESS
;
125 SupportedLanguage
+= 3;
128 if (EFI_ERROR (Status
)) {
132 if ((ActionRequired
== NULL
) || (ControllerHandle
== NULL
)) {
133 return EFI_INVALID_PARAMETER
;
136 if (ChildHandle
!= NULL
) {
137 return EFI_UNSUPPORTED
;
141 // Validate controller handle
143 Status
= gBS
->OpenProtocol (
145 &gEmuIoThunkProtocolGuid
,
147 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
149 EFI_OPEN_PROTOCOL_BY_DRIVER
152 if (!EFI_ERROR (Status
)) {
155 &gEmuIoThunkProtocolGuid
,
156 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
160 return EFI_UNSUPPORTED
;
163 if (Status
== EFI_UNSUPPORTED
) {
165 } else if (Status
!= EFI_ALREADY_STARTED
) {
166 return EFI_INVALID_PARAMETER
;
169 *ActionRequired
= EfiDriverConfigurationActionNone
;
176 Tests to see if a controller's current configuration options are valid.
179 This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
180 ControllerHandle - The handle of the controller to test if it's current
181 configuration options are valid.
182 ChildHandle - The handle of the child controller to test if it's current
183 configuration options are valid. This is an optional
184 parameter that may be NULL. It will be NULL for device
185 drivers. It will also be NULL for a bus drivers that wish
186 to test the configuration options for the bus controller.
187 It will not be NULL for a bus driver that wishes to test
188 configuration options for one of its child controllers.
191 EFI_SUCCESS - The controller specified by ControllerHandle and
192 ChildHandle that is being managed by the driver
193 specified by This has a valid set of configuration
195 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
196 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
197 EFI_UNSUPPORTED - The driver specified by This is not currently
198 managing the controller specified by ControllerHandle
200 EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
201 ChildHandle that is being managed by the driver
202 specified by This has an invalid set of configuration
208 EmuBlockIoDriverConfigurationOptionsValid (
209 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
210 IN EFI_HANDLE ControllerHandle
,
211 IN EFI_HANDLE ChildHandle OPTIONAL
215 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
217 if (ChildHandle
!= NULL
) {
218 return EFI_UNSUPPORTED
;
221 if (ControllerHandle
== NULL
) {
222 return EFI_INVALID_PARAMETER
;
226 // Validate controller handle
228 Status
= gBS
->OpenProtocol (
230 &gEmuIoThunkProtocolGuid
,
232 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
234 EFI_OPEN_PROTOCOL_BY_DRIVER
237 if (!EFI_ERROR (Status
)) {
240 &gEmuIoThunkProtocolGuid
,
241 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
245 return EFI_UNSUPPORTED
;
248 if (Status
== EFI_UNSUPPORTED
) {
250 } else if (Status
!= EFI_ALREADY_STARTED
) {
251 return EFI_INVALID_PARAMETER
;
260 Forces a driver to set the default configuration options for a controller.
263 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
264 ControllerHandle - The handle of the controller to force default configuration options on.
265 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.
266 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.
267 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.
270 EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.
271 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
272 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
273 EFI_INVALID_PARAMETER - ActionRequired is NULL.
274 EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.
275 EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.
276 EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
277 EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
282 EmuBlockIoDriverConfigurationForceDefaults (
283 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
284 IN EFI_HANDLE ControllerHandle
,
285 IN EFI_HANDLE ChildHandle OPTIONAL
,
286 IN UINT32 DefaultType
,
287 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
291 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
293 if (ChildHandle
!= NULL
) {
294 return EFI_UNSUPPORTED
;
297 if ((ActionRequired
== NULL
) || (ControllerHandle
== NULL
)) {
298 return EFI_INVALID_PARAMETER
;
302 // Validate controller handle
304 Status
= gBS
->OpenProtocol (
306 &gEmuIoThunkProtocolGuid
,
308 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
310 EFI_OPEN_PROTOCOL_BY_DRIVER
313 if (!EFI_ERROR (Status
)) {
316 &gEmuIoThunkProtocolGuid
,
317 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
321 return EFI_UNSUPPORTED
;
324 if (Status
== EFI_UNSUPPORTED
) {
326 } else if (Status
!= EFI_ALREADY_STARTED
) {
327 return EFI_INVALID_PARAMETER
;
330 *ActionRequired
= EfiDriverConfigurationActionNone
;