3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
15 #include <Protocol/BlockIo.h>
16 #include <Protocol/ComponentName.h>
17 #include <Protocol/DriverBinding.h>
19 #include "WinNtBlockIo.h"
22 // EFI Driver Configuration Functions
26 WinNtBlockIoDriverConfigurationSetOptions (
27 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
28 IN EFI_HANDLE ControllerHandle
,
29 IN EFI_HANDLE ChildHandle OPTIONAL
,
31 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
36 WinNtBlockIoDriverConfigurationOptionsValid (
37 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
38 IN EFI_HANDLE ControllerHandle
,
39 IN EFI_HANDLE ChildHandle OPTIONAL
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
53 // EFI Driver Configuration Protocol
55 EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration
= {
56 WinNtBlockIoDriverConfigurationSetOptions
,
57 WinNtBlockIoDriverConfigurationOptionsValid
,
58 WinNtBlockIoDriverConfigurationForceDefaults
,
64 WinNtBlockIoDriverConfigurationSetOptions (
65 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
66 IN EFI_HANDLE ControllerHandle
,
67 IN EFI_HANDLE ChildHandle OPTIONAL
,
69 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
74 Allows the user to set controller specific options for a controller that a
75 driver is currently managing.
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
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.
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.
119 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
120 CHAR8
*SupportedLanguage
;
122 SupportedLanguage
= This
->SupportedLanguages
;
124 Status
= EFI_UNSUPPORTED
;
125 while (*SupportedLanguage
!= 0) {
126 if (AsciiStrnCmp (Language
, SupportedLanguage
, 3) == 0) {
127 Status
= EFI_SUCCESS
;
130 SupportedLanguage
+= 3;
133 if (EFI_ERROR (Status
)) {
137 if (ActionRequired
== NULL
|| ControllerHandle
== NULL
) {
138 return EFI_INVALID_PARAMETER
;
141 if (ChildHandle
!= NULL
) {
142 return EFI_UNSUPPORTED
;
146 // Validate controller handle
148 Status
= gBS
->OpenProtocol (
150 &gEfiWinNtIoProtocolGuid
,
152 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
154 EFI_OPEN_PROTOCOL_BY_DRIVER
157 if (!EFI_ERROR (Status
)) {
160 &gEfiWinNtIoProtocolGuid
,
161 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
165 return EFI_UNSUPPORTED
;
168 if (Status
== EFI_UNSUPPORTED
) {
170 } else if (Status
!= EFI_ALREADY_STARTED
) {
171 return EFI_INVALID_PARAMETER
;
174 *ActionRequired
= EfiDriverConfigurationActionNone
;
180 WinNtBlockIoDriverConfigurationOptionsValid (
181 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
182 IN EFI_HANDLE ControllerHandle
,
183 IN EFI_HANDLE ChildHandle OPTIONAL
188 Tests to see if a controller's current configuration options are valid.
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.
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
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
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
220 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
222 if (ChildHandle
!= NULL
) {
223 return EFI_UNSUPPORTED
;
226 if (ControllerHandle
== NULL
) {
227 return EFI_INVALID_PARAMETER
;
231 // Validate controller handle
233 Status
= gBS
->OpenProtocol (
235 &gEfiWinNtIoProtocolGuid
,
237 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
239 EFI_OPEN_PROTOCOL_BY_DRIVER
242 if (!EFI_ERROR (Status
)) {
245 &gEfiWinNtIoProtocolGuid
,
246 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
250 return EFI_UNSUPPORTED
;
253 if (Status
== EFI_UNSUPPORTED
) {
255 } else if (Status
!= EFI_ALREADY_STARTED
) {
256 return EFI_INVALID_PARAMETER
;
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
274 Forces a driver to set the default configuration options for a controller.
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.
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.
296 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
298 if (ChildHandle
!= NULL
) {
299 return EFI_UNSUPPORTED
;
302 if (ActionRequired
== NULL
|| ControllerHandle
== NULL
) {
303 return EFI_INVALID_PARAMETER
;
307 // Validate controller handle
309 Status
= gBS
->OpenProtocol (
311 &gEfiWinNtIoProtocolGuid
,
313 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
315 EFI_OPEN_PROTOCOL_BY_DRIVER
318 if (!EFI_ERROR (Status
)) {
321 &gEfiWinNtIoProtocolGuid
,
322 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
326 return EFI_UNSUPPORTED
;
329 if (Status
== EFI_UNSUPPORTED
) {
331 } else if (Status
!= EFI_ALREADY_STARTED
) {
332 return EFI_INVALID_PARAMETER
;
335 *ActionRequired
= EfiDriverConfigurationActionNone
;