2 Implementation of UEFI Driver Configuration Protocol for IDE bus driver which
3 provides ability to set IDE bus controller specific options.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 CHAR16
*OptionString
[4] = {
20 L
"Enable Primary Master (Y/N)? -->",
21 L
"Enable Primary Slave (Y/N)? -->",
22 L
"Enable Secondary Master (Y/N)? -->",
23 L
"Enable Secondary Slave (Y/N)? -->"
27 // EFI Driver Configuration Protocol
29 EFI_DRIVER_CONFIGURATION_PROTOCOL gIDEBusDriverConfiguration
= {
30 IDEBusDriverConfigurationSetOptions
,
31 IDEBusDriverConfigurationOptionsValid
,
32 IDEBusDriverConfigurationForceDefaults
,
37 Interprete keyboard input.
39 @retval EFI_ABORTED Get an 'ESC' key inputed.
40 @retval EFI_SUCCESS Get an 'Y' or 'y' inputed.
41 @retval EFI_NOT_FOUND Get an 'N' or 'n' inputed..
53 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
54 if (!EFI_ERROR (Status
)) {
55 if (Key
.ScanCode
== SCAN_ESC
) {
59 switch (Key
.UnicodeChar
) {
66 gST
->ConOut
->OutputString (gST
->ConOut
, L
"Y\n");
74 gST
->ConOut
->OutputString (gST
->ConOut
, L
"N\n");
83 Allows the user to set controller specific options for a controller that a
84 driver is currently managing.
86 @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
87 @param ControllerHandle The handle of the controller to set options on.
88 @param ChildHandle The handle of the child controller to set options on.
89 This is an optional parameter that may be NULL.
90 It will be NULL for device drivers, and for a bus drivers
91 that wish to set options for the bus controller.
92 It will not be NULL for a bus driver that wishes to set
93 options for one of its child controllers.
94 @param Language A pointer to a three character ISO 639-2 language identifier.
95 This is the language of the user interface that should be presented
96 to the user, and it must match one of the languages specified in
97 SupportedLanguages. The number of languages supported by a driver is up to
99 @param ActionRequired A pointer to the action that the calling agent is required
100 to perform when this function returns.
103 @retval EFI_SUCCESS The driver specified by This successfully set the configuration
104 options for the controller specified by ControllerHandle..
105 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
106 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
107 @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
108 @retval EFI_UNSUPPORTED The driver specified by This does not support setting configuration options for
109 the controller specified by ControllerHandle and ChildHandle.
110 @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language.
111 @retval EFI_DEVICE_ERROR A device error occurred while attempt to set the configuration options for the
112 controller specified by ControllerHandle and ChildHandle.
113 @retval EFI_OUT_RESOURCES There are not enough resources available to set the configuration options for the
114 controller specified by ControllerHandle and ChildHandle
118 IDEBusDriverConfigurationSetOptions (
119 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
120 IN EFI_HANDLE ControllerHandle
,
121 IN EFI_HANDLE ChildHandle OPTIONAL
,
123 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
132 if (ChildHandle
!= NULL
) {
133 return EFI_UNSUPPORTED
;
136 *ActionRequired
= EfiDriverConfigurationActionNone
;
138 DataSize
= sizeof (Value
);
139 Status
= gRT
->GetVariable (
147 gST
->ConOut
->OutputString (gST
->ConOut
, L
"IDE Bus Driver Configuration\n");
148 gST
->ConOut
->OutputString (gST
->ConOut
, L
"===============================\n");
151 for (Index
= 0; Index
< 4; Index
++) {
152 gST
->ConOut
->OutputString (gST
->ConOut
, OptionString
[Index
]);
154 Status
= GetResponse ();
155 if (Status
== EFI_ABORTED
) {
159 if (!EFI_ERROR (Status
)) {
160 NewValue
= (UINT8
) (NewValue
| (1 << Index
));
164 if (EFI_ERROR (Status
) || (NewValue
!= Value
)) {
168 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
173 *ActionRequired
= EfiDriverConfigurationActionRestartController
;
175 *ActionRequired
= EfiDriverConfigurationActionNone
;
182 Tests to see if a controller's current configuration options are valid.
184 @param This A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
185 @param ControllerHandle The handle of the controller to test if it's current configuration options
187 @param ChildHandle The handle of the child controller to test if it's current configuration
188 options are valid. This is an optional parameter that may be NULL. It will
189 be NULL for device drivers. It will also be NULL for a bus drivers that
190 wish to test the configuration options for the bus controller. It will
191 not be NULL for a bus driver that wishes to test configuration options for
192 one of its child controllers.
193 @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle that is being
194 managed by the driver specified by This has a valid set of configuration
196 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
197 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
198 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller
199 specified by ControllerHandle and ChildHandle.
200 @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle that is being
201 managed by the driver specified by This has an invalid set of configuration
206 IDEBusDriverConfigurationOptionsValid (
207 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
208 IN EFI_HANDLE ControllerHandle
,
209 IN EFI_HANDLE ChildHandle OPTIONAL
216 if (ChildHandle
!= NULL
) {
217 return EFI_UNSUPPORTED
;
220 DataSize
= sizeof (Value
);
221 Status
= gRT
->GetVariable (
228 if (EFI_ERROR (Status
) || Value
> 0x0f) {
229 return EFI_DEVICE_ERROR
;
235 Forces a driver to set the default configuration options for a controller.
237 @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
238 @param ControllerHandle The handle of the controller to force default configuration options on.
239 @param ChildHandle The handle of the child controller to force default configuration
240 options on This is an optional parameter that may be NULL. It
241 will be NULL for device drivers. It will also be NULL for a bus
242 drivers that wish to force default configuration options for the bus
243 controller. It will not be NULL for a bus driver that wishes to force
244 default configuration options for one of its child controllers.
245 @param DefaultType The type of default configuration options to force on the controller
246 specified by ControllerHandle and ChildHandle.
247 @param ActionRequired A pointer to the action that the calling agent is required to perform
248 when this function returns.
250 @retval EFI_SUCCESS The driver specified by This successfully forced the
251 default configuration options on the controller specified by
252 ControllerHandle and ChildHandle.
253 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
254 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
255 @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
256 @retval EFI_UNSUPPORTED The driver specified by This does not support forcing the default
257 configuration options on the controller specified by ControllerHandle
259 @retval EFI_UNSUPPORTED The driver specified by This does not support the configuration type
260 specified by DefaultType.
261 @retval EFI_DEVICE_ERROR A device error occurred while attempt to force the default configuration
262 options on the controller specified by ControllerHandle and ChildHandle.
263 @retval EFI_OUT_RESOURCES There are not enough resources available to force the default configuration
264 options on the controller specified by ControllerHandle and ChildHandle.
268 IDEBusDriverConfigurationForceDefaults (
269 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
270 IN EFI_HANDLE ControllerHandle
,
271 IN EFI_HANDLE ChildHandle OPTIONAL
,
272 IN UINT32 DefaultType
,
273 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
278 if (ChildHandle
!= NULL
) {
279 return EFI_UNSUPPORTED
;
286 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
290 *ActionRequired
= EfiDriverConfigurationActionRestartController
;