3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include "PlatformSetupDxe.h"
19 #include "Guid/SetupVariable.h"
21 #define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')
22 #define EFI_CALLBACK_INFO_FROM_THIS(a) CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)
26 EFI_HANDLE DriverHandle
;
27 EFI_HII_HANDLE RegisteredHandle
;
28 SYSTEM_CONFIGURATION FakeNvData
;
29 SYSTEM_CONFIGURATION BackupNvData
;
30 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
31 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess
;
37 // HII specific Vendor Device Path definition.
40 VENDOR_DEVICE_PATH VendorDevicePath
;
41 EFI_DEVICE_PATH_PROTOCOL End
;
42 } HII_VENDOR_DEVICE_PATH
;
47 // uni string and Vfr Binary data.
49 extern UINT8 VfrBin
[];
50 extern UINT8 PlatformSetupDxeStrings
[];
52 EFI_HANDLE mImageHandle
;
57 #define EFI_NORMAL_SETUP_GUID \
58 { 0xec87d643, 0xeba4, 0x4bb5, 0xa1, 0xe5, 0x3f, 0x3e, 0x36, 0xb2, 0xd, 0xa9 }
60 EFI_GUID mNormalSetupGuid
= EFI_NORMAL_SETUP_GUID
;
62 EFI_GUID mSystemConfigGuid
= SYSTEM_CONFIGURATION_GUID
;
63 CHAR16 mVariableName
[] = L
"Setup";
64 CHAR16 mSetupName
[] = L
"Setup";
65 EFI_CALLBACK_INFO
*mCallbackInfo
;
66 BOOLEAN GlobalReset
=FALSE
;
68 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath
= {
74 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
75 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
82 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
84 (UINT8
) (END_DEVICE_PATH_LENGTH
),
85 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
91 This function allows a caller to extract the current configuration for one
92 or more named elements from the target driver.
94 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
95 @param Request A null-terminated Unicode string in <ConfigRequest> format.
96 @param Progress On return, points to a character in the Request string.
97 Points to the string's null terminator if request was successful.
98 Points to the most recent '&' before the first failing name/value
99 pair (or the beginning of the string if the failure is in the
100 first name/value pair) if the request was not successful.
101 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
102 has all values filled in for the names in the Request string.
103 String to be allocated by the called function.
105 @retval EFI_SUCCESS The Results is filled with the requested values.
106 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
107 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
108 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
113 CheckSystemConfigLoad(SYSTEM_CONFIGURATION
*SystemConfigPtr
);
116 CheckSystemConfigSave(SYSTEM_CONFIGURATION
*SystemConfigPtr
);
119 ConfirmSecureBootTest();
122 LoadLpssDefaultValues (
123 IN EFI_CALLBACK_INFO
*Private
127 // Load LPSS and SCC defalut configurations for Android
129 Private
->FakeNvData
.LpsseMMCEnabled
= FALSE
;
130 Private
->FakeNvData
.LpssSdioEnabled
= TRUE
;
131 Private
->FakeNvData
.LpssSdcardEnabled
= TRUE
;
132 Private
->FakeNvData
.LpssSdCardSDR25Enabled
= FALSE
;
133 Private
->FakeNvData
.LpssSdCardDDR50Enabled
= TRUE
;
134 Private
->FakeNvData
.LpssMipiHsi
= FALSE
;
135 Private
->FakeNvData
.LpsseMMC45Enabled
= TRUE
;
136 Private
->FakeNvData
.LpsseMMC45DDR50Enabled
= TRUE
;
137 Private
->FakeNvData
.LpsseMMC45HS200Enabled
= FALSE
;
138 Private
->FakeNvData
.LpsseMMC45RetuneTimerValue
= 8;
139 Private
->FakeNvData
.eMMCBootMode
= 1; // Auto Detect
141 Private
->FakeNvData
.GOPEnable
= TRUE
;
142 Private
->FakeNvData
.SecureBoot
= TRUE
;
143 Private
->FakeNvData
.UsbAutoMode
= TRUE
;
144 Private
->FakeNvData
.UsbXhciSupport
= TRUE
;
145 Private
->FakeNvData
.PchUsb30Mode
= TRUE
;
146 Private
->FakeNvData
.LegacyUSBBooting
= FALSE
;
147 Private
->FakeNvData
.PchUsb20
= FALSE
;
153 SystemConfigExtractConfig (
154 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
155 IN CONST EFI_STRING Request
,
156 OUT EFI_STRING
*Progress
,
157 OUT EFI_STRING
*Results
161 EFI_CALLBACK_INFO
*Private
;
162 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
163 EFI_STRING ConfigRequestHdr
;
164 EFI_STRING ConfigRequest
;
165 BOOLEAN AllocatedRequest
;
168 VOID
*SystemConfigPtr
;
171 if (Progress
== NULL
|| Results
== NULL
) {
172 return EFI_INVALID_PARAMETER
;
176 if ((Request
!= NULL
) && !HiiIsConfigHdrMatch (Request
, &mSystemConfigGuid
, mVariableName
)) {
177 return EFI_NOT_FOUND
;
180 ConfigRequestHdr
= NULL
;
181 ConfigRequest
= NULL
;
183 AllocatedRequest
= FALSE
;
185 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
189 HiiConfigRouting
= Private
->HiiConfigRouting
;
190 ConfigRequest
= Request
;
191 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
193 // Request has no request element, construct full request string.
194 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
195 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
197 ConfigRequestHdr
= HiiConstructConfigHdr (&mSystemConfigGuid
, mVariableName
, Private
->DriverHandle
);
198 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
199 ConfigRequest
= AllocateZeroPool (Size
);
200 ASSERT (ConfigRequest
!= NULL
);
201 AllocatedRequest
= TRUE
;
202 BufferSize
= sizeof (SYSTEM_CONFIGURATION
);
203 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr
, (UINT64
)BufferSize
);
204 FreePool (ConfigRequestHdr
);
206 SystemConfigPtr
= GetVariable(mSetupName
, &mNormalSetupGuid
);
209 if (SystemConfigPtr
== NULL
) {
210 ZeroMem(&Private
->FakeNvData
, sizeof(SYSTEM_CONFIGURATION
));
211 ZeroMem(&Private
->BackupNvData
, sizeof(SYSTEM_CONFIGURATION
));
213 CheckSystemConfigLoad(SystemConfigPtr
);
214 CopyMem(&Private
->FakeNvData
, SystemConfigPtr
, sizeof(SYSTEM_CONFIGURATION
));
215 CopyMem(&Private
->BackupNvData
, SystemConfigPtr
, sizeof(SYSTEM_CONFIGURATION
));
216 FreePool(SystemConfigPtr
);
220 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
222 Status
= HiiConfigRouting
->BlockToConfig (
225 (UINT8
*) &Private
->FakeNvData
,
226 sizeof (SYSTEM_CONFIGURATION
),
232 // Free the allocated config request string.
234 if (AllocatedRequest
) {
235 FreePool (ConfigRequest
);
236 ConfigRequest
= NULL
;
240 // Set Progress string to the original request string.
242 if (Request
== NULL
) {
244 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
245 *Progress
= Request
+ StrLen (Request
);
252 This function processes the results of changes in configuration.
254 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
255 @param Configuration A null-terminated Unicode string in <ConfigRequest> format.
256 @param Progress A pointer to a string filled in with the offset of the most
257 recent '&' before the first failing name/value pair (or the
258 beginning of the string if the failure is in the first
259 name/value pair) or the terminating NULL if all was successful.
261 @retval EFI_SUCCESS The Results is processed successfully.
262 @retval EFI_INVALID_PARAMETER Configuration is NULL.
263 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
268 SystemConfigRouteConfig (
269 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
270 IN CONST EFI_STRING Configuration
,
271 OUT EFI_STRING
*Progress
274 EFI_CALLBACK_INFO
*Private
;
275 SYSTEM_CONFIGURATION
*FakeNvData
;
277 if (Configuration
== NULL
|| Progress
== NULL
) {
278 return EFI_INVALID_PARAMETER
;
280 *Progress
= Configuration
;
282 if (!HiiIsConfigHdrMatch (Configuration
, &mSystemConfigGuid
, mVariableName
)) {
283 return EFI_NOT_FOUND
;
286 *Progress
= Configuration
+ StrLen (Configuration
);
287 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
288 FakeNvData
= &Private
->FakeNvData
;
289 if (!HiiGetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
)) {
291 // FakeNvData can't be got from SetupBrowser, which doesn't need to be set.
296 if (Private
->FakeNvData
.ReservedO
!= Private
->BackupNvData
.ReservedO
) {
297 Private
->BackupNvData
.ReservedO
= Private
->FakeNvData
.ReservedO
;
298 LoadLpssDefaultValues (Private
);
301 // Pass changed uncommitted data back to Form Browser
303 HiiSetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
, NULL
);
309 EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
310 sizeof(SYSTEM_CONFIGURATION
),
314 CheckSystemConfigSave(&Private
->FakeNvData
);
319 This is the function that is called to provide results data to the driver. This data
320 consists of a unique key which is used to identify what data is either being passed back
323 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
324 @param Action A null-terminated Unicode string in <ConfigRequest> format.
325 @param KeyValue A unique Goto OpCode callback value which record user's selection.
326 0x100 <= KeyValue <0x500 : user select a controller item in the first page;
327 KeyValue == 0x1234 : user select 'Refresh' in first page, or user select 'Go to Previous Menu' in second page
328 KeyValue == 0x1235 : user select 'Pci device filter' in first page
329 KeyValue == 0x1500 : user select 'order ... priority' item in second page
330 KeyValue == 0x1800 : user select 'commint changes' in third page
331 KeyValue == 0x2000 : user select 'Go to Previous Menu' in third page
332 @param Type The type of value for the question.
333 @param Value A pointer to the data being sent to the original exporting driver.
334 @param ActionRequest On return, points to the action requested by the callback function.
336 @retval EFI_SUCCESS Always returned.
341 SystemConfigCallback (
342 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
343 IN EFI_BROWSER_ACTION Action
,
344 IN EFI_QUESTION_ID KeyValue
,
346 IN EFI_IFR_TYPE_VALUE
*Value
,
347 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
350 EFI_CALLBACK_INFO
*Private
;
351 SYSTEM_CONFIGURATION
*FakeNvData
;
352 SYSTEM_CONFIGURATION
*SetupData
;
355 CHAR16
*StringBuffer1
;
356 CHAR16
*StringBuffer2
;
357 CHAR16
*StringBuffer3
;
362 StringBuffer1
= AllocateZeroPool (200 * sizeof (CHAR16
));
363 ASSERT (StringBuffer1
!= NULL
);
364 StringBuffer2
= AllocateZeroPool (200 * sizeof (CHAR16
));
365 ASSERT (StringBuffer2
!= NULL
);
366 StringBuffer3
= AllocateZeroPool (200 * sizeof (CHAR16
));
367 ASSERT (StringBuffer3
!= NULL
);
370 case EFI_BROWSER_ACTION_CHANGING
:
372 if (KeyValue
== 0x1235) {
373 StrCpy (StringBuffer1
, L
"Will you disable PTT ? ");
374 StrCpy (StringBuffer2
, L
"Enter (YES) / Esc (NO)");
377 // Popup a menu to notice user
380 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
381 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
384 // If the user hits the YES Response key,
386 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
389 } else if (KeyValue
== 0x1236) {
390 StrCpy (StringBuffer1
, L
"Will you revoke trust ? ");
391 StrCpy (StringBuffer2
, L
"Enter (YES) / Esc (NO)");
394 // Popup a menu to notice user
397 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
398 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
401 // If the user hits the YES Response key,
403 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
406 } else if (KeyValue
== 0x1239) {
407 if (Value
->u8
== 0x00) {
408 StrCpy (StringBuffer1
, L
"WARNING: SOC may be damaged due to high temperature");
409 StrCpy (StringBuffer2
, L
"when DPTF is disabled and IGD turbo is enabled.");
410 StrCpy (StringBuffer3
, L
"Press Enter/ESC to continue...");
413 // Popup a menu to notice user
416 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, StringBuffer3
, NULL
);
417 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
419 } else if (KeyValue
== 0x1240) { // secure erase feature of eMMC
421 // Popup a menu to notice user
423 StrCpy (StringBuffer1
, L
"WARNING: All your data on the eMMC will be lost");
424 StrCpy (StringBuffer2
, L
"Do you really want to enable secure erase on eMMC?");
425 StrCpy (StringBuffer3
, L
" Enter (YES) / Esc (NO) ");
428 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, StringBuffer3
,NULL
);
429 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
432 // If the user hits the ESC Response key,
434 if (Key
.ScanCode
== SCAN_ESC
) {
435 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
436 FakeNvData
= &Private
->FakeNvData
;
438 Status
= HiiGetBrowserData (
441 sizeof (SYSTEM_CONFIGURATION
),
444 if (!EFI_ERROR (Status
)) {
445 FakeNvData
->SecureErase
= 0;
449 sizeof (SYSTEM_CONFIGURATION
),
450 (UINT8
*) FakeNvData
,
458 // If the user hits the YES Response key
460 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
464 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
465 FakeNvData
= &Private
->FakeNvData
;
467 Status
= HiiGetBrowserData (
470 sizeof (SYSTEM_CONFIGURATION
),
473 if (!EFI_ERROR (Status
)) {
474 Status
= gRT
->SetVariable (
477 EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
478 sizeof(SYSTEM_CONFIGURATION
),
497 else if (KeyValue
== 0xF001) {
499 // Popup a menu to notice user
501 StrCpy (StringBuffer1
, L
"Do you want to Commit Changes and Exit?");
502 StrCpy (StringBuffer2
, L
" Enter (YES) / Esc (NO) ");
505 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
506 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
509 // If the user hits the YES Response key
511 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
515 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
516 FakeNvData
= &Private
->FakeNvData
;
518 Status
= HiiGetBrowserData (
521 sizeof (SYSTEM_CONFIGURATION
),
524 if (!EFI_ERROR (Status
)) {
525 Status
= gRT
->SetVariable (
528 EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
529 sizeof(SYSTEM_CONFIGURATION
),
535 // Update Secure Boot configuration changes
537 CheckSystemConfigSave(FakeNvData
);
542 if (GlobalReset
== TRUE
) {
564 } else if (KeyValue
== 0xF002) {
566 // Popup a menu to notice user
568 StrCpy (StringBuffer1
, L
"Do you want to Discard Changes and Exit?");
569 StrCpy (StringBuffer2
, L
" Enter (YES) / Esc (NO) ");
572 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
573 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
576 // If the user hits the YES Response key
578 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
582 gRT
->ResetSystem(EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
584 } else if (KeyValue
== 0xF003) {
586 // Popup a menu to notice user
588 StrCpy (StringBuffer1
, L
"Do you want to load setup defaults and Exit?");
589 StrCpy (StringBuffer2
, L
" Enter (YES) / Esc (NO) ");
592 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
593 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
596 // If the user hits the YES Response key
598 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
602 FakeNvData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
604 if (FakeNvData
== NULL
) {
605 return EFI_OUT_OF_RESOURCES
;
608 SizeOfNvStore
= sizeof(SYSTEM_CONFIGURATION
);
609 Status
= gRT
->GetVariable(
616 if (!EFI_ERROR (Status
)) {
617 if(SizeOfNvStore
>= sizeof(SYSTEM_CONFIGURATION
)) {
618 Status
= gRT
->SetVariable (
621 EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
622 sizeof(SYSTEM_CONFIGURATION
),
628 FreePool (FakeNvData
);
630 DataSize
= sizeof(OsSelection
);
631 Status
= gRT
->GetVariable(
633 &gOsSelectionVariableGuid
,
639 if (EFI_ERROR(Status
) || (OsSelection
!= FakeNvData
->ReservedO
)) {
640 OsSelection
= FakeNvData
->ReservedO
;
641 Status
= gRT
->SetVariable (
643 &gOsSelectionVariableGuid
,
644 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
660 } else if ((KeyValue
== 0x123A) || (KeyValue
== 0x123B) || (KeyValue
== 0x123C)) {
661 StrCpy (StringBuffer1
, L
"WARNING: Enable or disable USB Controllers will ");
662 StrCpy (StringBuffer2
, L
"make global reset to restart system.");
663 StrCpy (StringBuffer3
, L
"Press Enter/ESC to continue...");
665 // Popup a menu to notice user
668 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, StringBuffer3
, NULL
);
669 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
671 FakeNvData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
672 Status
= HiiGetBrowserData (
675 sizeof (SYSTEM_CONFIGURATION
),
681 SizeOfNvStore
= sizeof(SYSTEM_CONFIGURATION
);
682 SetupData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
683 Status
= gRT
->GetVariable(
690 if ((SetupData
->UsbAutoMode
!= FakeNvData
->UsbAutoMode
) ||
691 (SetupData
->UsbXhciSupport
!= FakeNvData
->UsbXhciSupport
) ||
692 (SetupData
->PchUsb20
!= FakeNvData
->PchUsb20
)) {
706 FreePool (StringBuffer1
);
707 FreePool (StringBuffer2
);
708 FreePool (StringBuffer3
);
711 // Workaround for Load Default for "DPTF Enable"
713 if (Action
== EFI_BROWSER_ACTION_DEFAULT_STANDARD
) {
714 if (KeyValue
== 0x1239) {
715 return EFI_NOT_FOUND
;
719 if (Action
== EFI_BROWSER_ACTION_FORM_CLOSE
) {
721 // Do nothing for UEFI OPEN/CLOSE Action
726 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
727 FakeNvData
= &Private
->FakeNvData
;
728 if (!HiiGetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
)) {
729 return EFI_NOT_FOUND
;
732 if ((Action
== EFI_BROWSER_ACTION_FORM_OPEN
) && (Private
->FakeNvData
.ReservedO
!= Private
->BackupNvData
.ReservedO
)) {
733 Private
->BackupNvData
.ReservedO
= Private
->FakeNvData
.ReservedO
;
734 LoadLpssDefaultValues (Private
);
738 // When user selected the secure erase, set it to disable
740 if((KeyValue
== 0x1240) && (Action
== EFI_BROWSER_ACTION_CHANGED
)) {
741 FakeNvData
->SecureErase
= 0;
744 if ((Action
== EFI_BROWSER_ACTION_FORM_OPEN
) || (Action
== EFI_BROWSER_ACTION_CHANGED
)) {
746 // If function 0 is disabled, function 1 ~ 7 also required to be disabled.
748 if (Private
->FakeNvData
.LpssDma0Enabled
== 0) {
749 Private
->FakeNvData
.LpssHsuart0Enabled
= 0;
750 Private
->FakeNvData
.LpssHsuart1Enabled
= 0;
751 Private
->FakeNvData
.LpssPwm0Enabled
= 0;
752 Private
->FakeNvData
.LpssPwm1Enabled
= 0;
753 Private
->FakeNvData
.LpssSpiEnabled
= 0;
758 // If function 0 is disabled, function 1 ~ 7 also required to be disabled.
760 if (Private
->FakeNvData
.LpssDma1Enabled
== 0) {
761 Private
->FakeNvData
.LpssI2C0Enabled
= 0;
762 Private
->FakeNvData
.LpssI2C1Enabled
= 0;
763 Private
->FakeNvData
.LpssI2C2Enabled
= 0;
764 Private
->FakeNvData
.LpssI2C3Enabled
= 0;
765 Private
->FakeNvData
.LpssI2C4Enabled
= 0;
766 Private
->FakeNvData
.LpssI2C5Enabled
= 0;
767 Private
->FakeNvData
.LpssI2C6Enabled
= 0;
773 // Pass changed uncommitted data back to Form Browser
775 HiiSetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
, NULL
);
782 The driver Entry Point. The funciton will export a disk device class formset and
783 its callback function to hii database.
785 @param ImageHandle The firmware allocated handle for the EFI image.
786 @param SystemTable A pointer to the EFI System Table.
788 @retval EFI_SUCCESS The entry point is executed successfully.
789 @retval other Some error occurs when executing this entry point.
794 PlatformSetupDxeInit (
795 IN EFI_HANDLE ImageHandle
,
796 IN EFI_SYSTEM_TABLE
*SystemTable
800 EFI_FORM_BROWSER2_PROTOCOL
*FormBrowser2
;
802 mImageHandle
= ImageHandle
;
805 // There should only be one Form Configuration protocol
807 Status
= gBS
->LocateProtocol (
808 &gEfiFormBrowser2ProtocolGuid
,
810 (VOID
**) &FormBrowser2
812 if (EFI_ERROR (Status
)) {
816 mCallbackInfo
= AllocateZeroPool (sizeof (EFI_CALLBACK_INFO
));
817 if (mCallbackInfo
== NULL
) {
818 return EFI_BAD_BUFFER_SIZE
;
821 mCallbackInfo
->Signature
= EFI_CALLBACK_INFO_SIGNATURE
;
822 mCallbackInfo
->ConfigAccess
.ExtractConfig
= SystemConfigExtractConfig
;
823 mCallbackInfo
->ConfigAccess
.RouteConfig
= SystemConfigRouteConfig
;
824 mCallbackInfo
->ConfigAccess
.Callback
= SystemConfigCallback
;
827 // Install Device Path Protocol and Config Access protocol to driver handle
828 // Install Platform Driver Override Protocol to driver handle
830 Status
= gBS
->InstallMultipleProtocolInterfaces (
831 &mCallbackInfo
->DriverHandle
,
832 &gEfiDevicePathProtocolGuid
,
833 &mHiiVendorDevicePath
,
834 &gEfiHiiConfigAccessProtocolGuid
,
835 &mCallbackInfo
->ConfigAccess
,
838 if (EFI_ERROR (Status
)) {
843 // Publish our HII data
845 mCallbackInfo
->RegisteredHandle
= HiiAddPackages (
847 mCallbackInfo
->DriverHandle
,
849 PlatformSetupDxeStrings
,
852 if (mCallbackInfo
->RegisteredHandle
== NULL
) {
853 Status
= EFI_OUT_OF_RESOURCES
;
857 mHiiHandle
= mCallbackInfo
->RegisteredHandle
;
860 // Locate ConfigRouting protocol
862 Status
= gBS
->LocateProtocol (
863 &gEfiHiiConfigRoutingProtocolGuid
,
865 (VOID
**) &mCallbackInfo
->HiiConfigRouting
867 if (EFI_ERROR (Status
)) {
872 // Clear all the globle variable
877 if (mCallbackInfo
->DriverHandle
!= NULL
) {
878 gBS
->UninstallMultipleProtocolInterfaces (
879 mCallbackInfo
->DriverHandle
,
880 &gEfiDevicePathProtocolGuid
,
881 &mHiiVendorDevicePath
,
882 &gEfiHiiConfigAccessProtocolGuid
,
883 &mCallbackInfo
->ConfigAccess
,
888 if (mCallbackInfo
->RegisteredHandle
!= NULL
) {
889 HiiRemovePackages (mCallbackInfo
->RegisteredHandle
);
892 if (mCallbackInfo
!= NULL
) {
893 FreePool (mCallbackInfo
);
900 Unload its installed protocol.
902 @param[in] ImageHandle Handle that identifies the image to be unloaded.
904 @retval EFI_SUCCESS The image has been unloaded.
908 PlatformSetupDxeUnload (
909 IN EFI_HANDLE ImageHandle
912 if (mCallbackInfo
!= NULL
) {
913 if (mCallbackInfo
->DriverHandle
!= NULL
) {
914 gBS
->UninstallMultipleProtocolInterfaces (
915 mCallbackInfo
->DriverHandle
,
916 &gEfiDevicePathProtocolGuid
,
917 &mHiiVendorDevicePath
,
918 &gEfiHiiConfigAccessProtocolGuid
,
919 &mCallbackInfo
->ConfigAccess
,
924 if (mCallbackInfo
->RegisteredHandle
!= NULL
) {
925 HiiRemovePackages (mCallbackInfo
->RegisteredHandle
);
928 FreePool (mCallbackInfo
);