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.
21 #include <Protocol/BlockIo.h>
22 #include <Protocol/ComponentName.h>
23 #include <Protocol/DriverBinding.h>
25 #include "WinNtBlockIo.h"
28 // EFI Driver Configuration Functions
32 WinNtBlockIoDriverConfigurationSetOptions (
33 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
34 IN EFI_HANDLE ControllerHandle
,
35 IN EFI_HANDLE ChildHandle OPTIONAL
,
37 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
42 WinNtBlockIoDriverConfigurationOptionsValid (
43 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
44 IN EFI_HANDLE ControllerHandle
,
45 IN EFI_HANDLE ChildHandle OPTIONAL
50 WinNtBlockIoDriverConfigurationForceDefaults (
51 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
52 IN EFI_HANDLE ControllerHandle
,
53 IN EFI_HANDLE ChildHandle OPTIONAL
,
54 IN UINT32 DefaultType
,
55 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
59 // EFI Driver Configuration Protocol
61 EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration
= {
62 WinNtBlockIoDriverConfigurationSetOptions
,
63 WinNtBlockIoDriverConfigurationOptionsValid
,
64 WinNtBlockIoDriverConfigurationForceDefaults
,
70 WinNtBlockIoDriverConfigurationSetOptions (
71 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
72 IN EFI_HANDLE ControllerHandle
,
73 IN EFI_HANDLE ChildHandle OPTIONAL
,
75 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
80 Allows the user to set controller specific options for a controller that a
81 driver is currently managing.
84 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
85 ControllerHandle - The handle of the controller to set options on.
86 ChildHandle - The handle of the child controller to set options on. This
87 is an optional parameter that may be NULL. It will be NULL
88 for device drivers, and for a bus drivers that wish to set
89 options for the bus controller. It will not be NULL for a
90 bus driver that wishes to set options for one of its child
92 Language - A pointer to a three character ISO 639-2 language identifier.
93 This is the language of the user interface that should be
94 presented to the user, and it must match one of the languages
95 specified in SupportedLanguages. The number of languages
96 supported by a driver is up to the driver writer.
97 ActionRequired - A pointer to the action that the calling agent is required
98 to perform when this function returns. See "Related
99 Definitions" for a list of the actions that the calling
100 agent is required to perform prior to accessing
101 ControllerHandle again.
104 EFI_SUCCESS - The driver specified by This successfully set the
105 configuration options for the controller specified
106 by ControllerHandle..
107 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
108 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
109 EFI_INVALID_PARAMETER - ActionRequired is NULL.
110 EFI_UNSUPPORTED - The driver specified by This does not support setting
111 configuration options for the controller specified by
112 ControllerHandle and ChildHandle.
113 EFI_UNSUPPORTED - The driver specified by This does not support the
114 language specified by Language.
115 EFI_DEVICE_ERROR - A device error occurred while attempt to set the
116 configuration options for the controller specified
117 by ControllerHandle and ChildHandle.
118 EFI_OUT_RESOURCES - There are not enough resources available to set the
119 configuration options for the controller specified
120 by ControllerHandle and ChildHandle.
125 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
126 CHAR8
*SupportedLanguage
;
128 SupportedLanguage
= This
->SupportedLanguages
;
130 Status
= EFI_UNSUPPORTED
;
131 while (*SupportedLanguage
!= 0) {
132 if (AsciiStrnCmp (Language
, SupportedLanguage
, 3) == 0) {
133 Status
= EFI_SUCCESS
;
136 SupportedLanguage
+= 3;
139 if (EFI_ERROR (Status
)) {
143 if (ActionRequired
== NULL
|| ControllerHandle
== NULL
) {
144 return EFI_INVALID_PARAMETER
;
147 if (ChildHandle
!= NULL
) {
148 return EFI_UNSUPPORTED
;
152 // Validate controller handle
154 Status
= gBS
->OpenProtocol (
156 &gEfiWinNtIoProtocolGuid
,
158 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
160 EFI_OPEN_PROTOCOL_BY_DRIVER
163 if (!EFI_ERROR (Status
)) {
166 &gEfiWinNtIoProtocolGuid
,
167 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
171 return EFI_UNSUPPORTED
;
174 if (Status
== EFI_UNSUPPORTED
) {
176 } else if (Status
!= EFI_ALREADY_STARTED
) {
177 return EFI_INVALID_PARAMETER
;
180 *ActionRequired
= EfiDriverConfigurationActionNone
;
186 WinNtBlockIoDriverConfigurationOptionsValid (
187 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
188 IN EFI_HANDLE ControllerHandle
,
189 IN EFI_HANDLE ChildHandle OPTIONAL
194 Tests to see if a controller's current configuration options are valid.
197 This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
198 ControllerHandle - The handle of the controller to test if it's current
199 configuration options are valid.
200 ChildHandle - The handle of the child controller to test if it's current
201 configuration options are valid. This is an optional
202 parameter that may be NULL. It will be NULL for device
203 drivers. It will also be NULL for a bus drivers that wish
204 to test the configuration options for the bus controller.
205 It will not be NULL for a bus driver that wishes to test
206 configuration options for one of its child controllers.
209 EFI_SUCCESS - The controller specified by ControllerHandle and
210 ChildHandle that is being managed by the driver
211 specified by This has a valid set of configuration
213 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
214 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
215 EFI_UNSUPPORTED - The driver specified by This is not currently
216 managing the controller specified by ControllerHandle
218 EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
219 ChildHandle that is being managed by the driver
220 specified by This has an invalid set of configuration
226 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
228 if (ChildHandle
!= NULL
) {
229 return EFI_UNSUPPORTED
;
232 if (ControllerHandle
== NULL
) {
233 return EFI_INVALID_PARAMETER
;
237 // Validate controller handle
239 Status
= gBS
->OpenProtocol (
241 &gEfiWinNtIoProtocolGuid
,
243 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
245 EFI_OPEN_PROTOCOL_BY_DRIVER
248 if (!EFI_ERROR (Status
)) {
251 &gEfiWinNtIoProtocolGuid
,
252 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
256 return EFI_UNSUPPORTED
;
259 if (Status
== EFI_UNSUPPORTED
) {
261 } else if (Status
!= EFI_ALREADY_STARTED
) {
262 return EFI_INVALID_PARAMETER
;
270 WinNtBlockIoDriverConfigurationForceDefaults (
271 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
272 IN EFI_HANDLE ControllerHandle
,
273 IN EFI_HANDLE ChildHandle OPTIONAL
,
274 IN UINT32 DefaultType
,
275 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
280 Forces a driver to set the default configuration options for a controller.
283 This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
284 ControllerHandle - The handle of the controller to force default configuration options on.
285 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.
286 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.
287 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.
290 EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.
291 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
292 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
293 EFI_INVALID_PARAMETER - ActionRequired is NULL.
294 EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.
295 EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.
296 EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
297 EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
302 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
304 if (ChildHandle
!= NULL
) {
305 return EFI_UNSUPPORTED
;
308 if (ActionRequired
== NULL
|| ControllerHandle
== NULL
) {
309 return EFI_INVALID_PARAMETER
;
313 // Validate controller handle
315 Status
= gBS
->OpenProtocol (
317 &gEfiWinNtIoProtocolGuid
,
319 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
321 EFI_OPEN_PROTOCOL_BY_DRIVER
324 if (!EFI_ERROR (Status
)) {
327 &gEfiWinNtIoProtocolGuid
,
328 gWinNtBlockIoDriverBinding
.DriverBindingHandle
,
332 return EFI_UNSUPPORTED
;
335 if (Status
== EFI_UNSUPPORTED
) {
337 } else if (Status
!= EFI_ALREADY_STARTED
) {
338 return EFI_INVALID_PARAMETER
;
341 *ActionRequired
= EfiDriverConfigurationActionNone
;