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"
20 #include <Protocol/FormBrowserEx2.h>
23 #define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')
24 #define EFI_CALLBACK_INFO_FROM_THIS(a) CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)
28 EFI_HANDLE DriverHandle
;
29 EFI_HII_HANDLE RegisteredHandle
;
30 SYSTEM_CONFIGURATION FakeNvData
;
31 SYSTEM_CONFIGURATION BackupNvData
;
32 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
33 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess
;
39 // HII specific Vendor Device Path definition.
42 VENDOR_DEVICE_PATH VendorDevicePath
;
43 EFI_DEVICE_PATH_PROTOCOL End
;
44 } HII_VENDOR_DEVICE_PATH
;
49 // uni string and Vfr Binary data.
51 extern UINT8 VfrBin
[];
52 extern UINT8 PlatformSetupDxeStrings
[];
54 EFI_HANDLE mImageHandle
;
59 #define EFI_NORMAL_SETUP_GUID \
60 { 0xec87d643, 0xeba4, 0x4bb5, 0xa1, 0xe5, 0x3f, 0x3e, 0x36, 0xb2, 0xd, 0xa9 }
62 EFI_GUID mNormalSetupGuid
= EFI_NORMAL_SETUP_GUID
;
64 EFI_GUID mSystemConfigGuid
= SYSTEM_CONFIGURATION_GUID
;
65 CHAR16 mVariableName
[] = L
"Setup";
66 CHAR16 mSetupName
[] = L
"Setup";
67 EFI_CALLBACK_INFO
*mCallbackInfo
;
68 BOOLEAN GlobalReset
=FALSE
;
70 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath
= {
76 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
77 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
84 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
86 (UINT8
) (END_DEVICE_PATH_LENGTH
),
87 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
93 This function allows a caller to extract the current configuration for one
94 or more named elements from the target driver.
96 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
97 @param Request A null-terminated Unicode string in <ConfigRequest> format.
98 @param Progress On return, points to a character in the Request string.
99 Points to the string's null terminator if request was successful.
100 Points to the most recent '&' before the first failing name/value
101 pair (or the beginning of the string if the failure is in the
102 first name/value pair) if the request was not successful.
103 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
104 has all values filled in for the names in the Request string.
105 String to be allocated by the called function.
107 @retval EFI_SUCCESS The Results is filled with the requested values.
108 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
109 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
110 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
115 CheckSystemConfigLoad(SYSTEM_CONFIGURATION
*SystemConfigPtr
);
118 CheckSystemConfigSave(SYSTEM_CONFIGURATION
*SystemConfigPtr
);
121 ConfirmSecureBootTest();
124 LoadLpssDefaultValues (
125 IN EFI_CALLBACK_INFO
*Private
129 // Load LPSS and SCC default configurations for Android
131 Private
->FakeNvData
.LpsseMMCEnabled
= FALSE
;
132 Private
->FakeNvData
.LpssSdioEnabled
= TRUE
;
133 Private
->FakeNvData
.LpssSdcardEnabled
= TRUE
;
134 Private
->FakeNvData
.LpssSdCardSDR25Enabled
= FALSE
;
135 Private
->FakeNvData
.LpssSdCardDDR50Enabled
= TRUE
;
136 Private
->FakeNvData
.LpssMipiHsi
= FALSE
;
137 Private
->FakeNvData
.LpsseMMC45Enabled
= TRUE
;
138 Private
->FakeNvData
.LpsseMMC45DDR50Enabled
= TRUE
;
139 Private
->FakeNvData
.LpsseMMC45HS200Enabled
= FALSE
;
140 Private
->FakeNvData
.LpsseMMC45RetuneTimerValue
= 8;
141 Private
->FakeNvData
.eMMCBootMode
= 1; // Auto Detect
143 Private
->FakeNvData
.GOPEnable
= TRUE
;
144 Private
->FakeNvData
.SecureBoot
= TRUE
;
145 Private
->FakeNvData
.UsbAutoMode
= TRUE
;
146 Private
->FakeNvData
.UsbXhciSupport
= TRUE
;
147 Private
->FakeNvData
.PchUsb30Mode
= TRUE
;
148 Private
->FakeNvData
.LegacyUSBBooting
= FALSE
;
149 Private
->FakeNvData
.PchUsb20
= FALSE
;
155 SystemConfigExtractConfig (
156 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
157 IN CONST EFI_STRING Request
,
158 OUT EFI_STRING
*Progress
,
159 OUT EFI_STRING
*Results
163 EFI_CALLBACK_INFO
*Private
;
164 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
165 EFI_STRING ConfigRequestHdr
;
166 EFI_STRING ConfigRequest
;
167 BOOLEAN AllocatedRequest
;
170 VOID
*SystemConfigPtr
;
173 if (Progress
== NULL
|| Results
== NULL
) {
174 return EFI_INVALID_PARAMETER
;
178 if ((Request
!= NULL
) && !HiiIsConfigHdrMatch (Request
, &mSystemConfigGuid
, mVariableName
)) {
179 return EFI_NOT_FOUND
;
182 ConfigRequestHdr
= NULL
;
183 ConfigRequest
= NULL
;
185 AllocatedRequest
= FALSE
;
187 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
191 HiiConfigRouting
= Private
->HiiConfigRouting
;
192 ConfigRequest
= Request
;
193 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
195 // Request has no request element, construct full request string.
196 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
197 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
199 ConfigRequestHdr
= HiiConstructConfigHdr (&mSystemConfigGuid
, mVariableName
, Private
->DriverHandle
);
200 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
201 ConfigRequest
= AllocateZeroPool (Size
);
202 ASSERT (ConfigRequest
!= NULL
);
203 AllocatedRequest
= TRUE
;
204 BufferSize
= sizeof (SYSTEM_CONFIGURATION
);
205 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr
, (UINT64
)BufferSize
);
206 FreePool (ConfigRequestHdr
);
208 SystemConfigPtr
= GetVariable(mSetupName
, &mNormalSetupGuid
);
211 if (SystemConfigPtr
== NULL
) {
212 ZeroMem(&Private
->FakeNvData
, sizeof(SYSTEM_CONFIGURATION
));
213 ZeroMem(&Private
->BackupNvData
, sizeof(SYSTEM_CONFIGURATION
));
215 CheckSystemConfigLoad(SystemConfigPtr
);
216 CopyMem(&Private
->FakeNvData
, SystemConfigPtr
, sizeof(SYSTEM_CONFIGURATION
));
217 CopyMem(&Private
->BackupNvData
, SystemConfigPtr
, sizeof(SYSTEM_CONFIGURATION
));
218 FreePool(SystemConfigPtr
);
222 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
224 Status
= HiiConfigRouting
->BlockToConfig (
227 (UINT8
*) &Private
->FakeNvData
,
228 sizeof (SYSTEM_CONFIGURATION
),
234 // Free the allocated config request string.
236 if (AllocatedRequest
) {
237 FreePool (ConfigRequest
);
238 ConfigRequest
= NULL
;
242 // Set Progress string to the original request string.
244 if (Request
== NULL
) {
246 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
247 *Progress
= Request
+ StrLen (Request
);
254 This function processes the results of changes in configuration.
256 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
257 @param Configuration A null-terminated Unicode string in <ConfigRequest> format.
258 @param Progress A pointer to a string filled in with the offset of the most
259 recent '&' before the first failing name/value pair (or the
260 beginning of the string if the failure is in the first
261 name/value pair) or the terminating NULL if all was successful.
263 @retval EFI_SUCCESS The Results is processed successfully.
264 @retval EFI_INVALID_PARAMETER Configuration is NULL.
265 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
270 SystemConfigRouteConfig (
271 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
272 IN CONST EFI_STRING Configuration
,
273 OUT EFI_STRING
*Progress
276 EFI_CALLBACK_INFO
*Private
;
277 SYSTEM_CONFIGURATION
*FakeNvData
;
279 if (Configuration
== NULL
|| Progress
== NULL
) {
280 return EFI_INVALID_PARAMETER
;
282 *Progress
= Configuration
;
284 if (!HiiIsConfigHdrMatch (Configuration
, &mSystemConfigGuid
, mVariableName
)) {
285 return EFI_NOT_FOUND
;
288 *Progress
= Configuration
+ StrLen (Configuration
);
289 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
290 FakeNvData
= &Private
->FakeNvData
;
291 if (!HiiGetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
)) {
293 // FakeNvData can't be got from SetupBrowser, which doesn't need to be set.
298 if (Private
->FakeNvData
.ReservedO
!= Private
->BackupNvData
.ReservedO
) {
299 Private
->BackupNvData
.ReservedO
= Private
->FakeNvData
.ReservedO
;
300 LoadLpssDefaultValues (Private
);
303 // Pass changed uncommitted data back to Form Browser
305 HiiSetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
, NULL
);
311 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
312 sizeof(SYSTEM_CONFIGURATION
),
316 CheckSystemConfigSave(&Private
->FakeNvData
);
321 This is the function that is called to provide results data to the driver. This data
322 consists of a unique key which is used to identify what data is either being passed back
325 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
326 @param Action A null-terminated Unicode string in <ConfigRequest> format.
327 @param KeyValue A unique Goto OpCode callback value which record user's selection.
328 0x100 <= KeyValue <0x500 : user select a controller item in the first page;
329 KeyValue == 0x1234 : user select 'Refresh' in first page, or user select 'Go to Previous Menu' in second page
330 KeyValue == 0x1235 : user select 'Pci device filter' in first page
331 KeyValue == 0x1500 : user select 'order ... priority' item in second page
332 KeyValue == 0x1800 : user select 'commint changes' in third page
333 KeyValue == 0x2000 : user select 'Go to Previous Menu' in third page
334 @param Type The type of value for the question.
335 @param Value A pointer to the data being sent to the original exporting driver.
336 @param ActionRequest On return, points to the action requested by the callback function.
338 @retval EFI_SUCCESS Always returned.
343 SystemConfigCallback (
344 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
345 IN EFI_BROWSER_ACTION Action
,
346 IN EFI_QUESTION_ID KeyValue
,
348 IN EFI_IFR_TYPE_VALUE
*Value
,
349 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
352 EFI_CALLBACK_INFO
*Private
;
353 SYSTEM_CONFIGURATION
*FakeNvData
;
354 SYSTEM_CONFIGURATION
*SetupData
;
357 CHAR16
*StringBuffer1
;
358 CHAR16
*StringBuffer2
;
359 CHAR16
*StringBuffer3
;
363 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
365 StringBuffer1
= AllocateZeroPool (200 * sizeof (CHAR16
));
366 ASSERT (StringBuffer1
!= NULL
);
367 StringBuffer2
= AllocateZeroPool (200 * sizeof (CHAR16
));
368 ASSERT (StringBuffer2
!= NULL
);
369 StringBuffer3
= AllocateZeroPool (200 * sizeof (CHAR16
));
370 ASSERT (StringBuffer3
!= NULL
);
373 case EFI_BROWSER_ACTION_CHANGING
:
375 if (KeyValue
== 0x1235) {
376 StrCpy (StringBuffer1
, L
"Will you disable PTT ? ");
377 StrCpy (StringBuffer2
, L
"Enter (YES) / Esc (NO)");
380 // Popup a menu to notice user
383 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
384 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
387 // If the user hits the YES Response key,
389 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
392 } else if (KeyValue
== 0x1236) {
393 StrCpy (StringBuffer1
, L
"Will you revoke trust ? ");
394 StrCpy (StringBuffer2
, L
"Enter (YES) / Esc (NO)");
397 // Popup a menu to notice user
400 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
401 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
404 // If the user hits the YES Response key,
406 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
409 } else if (KeyValue
== 0x1239) {
410 if (Value
->u8
== 0x00) {
411 StrCpy (StringBuffer1
, L
"WARNING: SOC may be damaged due to high temperature");
412 StrCpy (StringBuffer2
, L
"when DPTF is disabled and IGD turbo is enabled.");
413 StrCpy (StringBuffer3
, L
"Press Enter/ESC to continue...");
416 // Popup a menu to notice user
419 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, StringBuffer3
, NULL
);
420 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
422 } else if (KeyValue
== 0x1240) { // secure erase feature of eMMC
424 // Popup a menu to notice user
426 StrCpy (StringBuffer1
, L
"WARNING: All your data on the eMMC will be lost");
427 StrCpy (StringBuffer2
, L
"Do you really want to enable secure erase on eMMC?");
428 StrCpy (StringBuffer3
, L
" Enter (YES) / Esc (NO) ");
431 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, StringBuffer3
,NULL
);
432 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
435 // If the user hits the ESC Response key,
437 if (Key
.ScanCode
== SCAN_ESC
) {
438 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
439 FakeNvData
= &Private
->FakeNvData
;
441 Status
= HiiGetBrowserData (
444 sizeof (SYSTEM_CONFIGURATION
),
447 if (!EFI_ERROR (Status
)) {
448 FakeNvData
->SecureErase
= 0;
452 sizeof (SYSTEM_CONFIGURATION
),
453 (UINT8
*) FakeNvData
,
461 // If the user hits the YES Response key
463 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
467 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
468 FakeNvData
= &Private
->FakeNvData
;
470 Status
= HiiGetBrowserData (
473 sizeof (SYSTEM_CONFIGURATION
),
476 if (!EFI_ERROR (Status
)) {
477 Status
= gRT
->SetVariable (
480 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
481 sizeof(SYSTEM_CONFIGURATION
),
500 else if (KeyValue
== 0xF001) {
502 // Popup a menu to notice user
504 StrCpy (StringBuffer1
, L
"Do you want to Commit Changes and Exit?");
505 StrCpy (StringBuffer2
, L
" Enter (YES) / Esc (NO) ");
508 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
509 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
512 // If the user hits the YES Response key
514 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
518 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
519 FakeNvData
= &Private
->FakeNvData
;
521 Status
= HiiGetBrowserData (
524 sizeof (SYSTEM_CONFIGURATION
),
527 if (!EFI_ERROR (Status
)) {
528 Status
= gRT
->SetVariable (
531 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
532 sizeof(SYSTEM_CONFIGURATION
),
538 // Update Secure Boot configuration changes
540 CheckSystemConfigSave(FakeNvData
);
545 if (GlobalReset
== TRUE
) {
567 } else if (KeyValue
== 0xF002) {
569 // Popup a menu to notice user
571 StrCpy (StringBuffer1
, L
"Do you want to Discard Changes and Exit?");
572 StrCpy (StringBuffer2
, L
" Enter (YES) / Esc (NO) ");
575 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
576 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
579 // If the user hits the YES Response key
581 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
585 gRT
->ResetSystem(EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
587 } else if (KeyValue
== 0xF003) {
589 // Popup a menu to notice user
591 StrCpy (StringBuffer1
, L
"Do you want to load setup defaults and Exit?");
592 StrCpy (StringBuffer2
, L
" Enter (YES) / Esc (NO) ");
595 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, NULL
);
596 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
599 // If the user hits the YES Response key
601 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
603 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
604 FormBrowserEx2
->ExecuteAction(BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
);
606 FakeNvData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
608 if (FakeNvData
== NULL
) {
609 return EFI_OUT_OF_RESOURCES
;
612 Status
= HiiGetBrowserData (
615 sizeof (SYSTEM_CONFIGURATION
),
619 if (!EFI_ERROR (Status
)) {
620 Status
= gRT
->SetVariable (
623 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
624 sizeof(SYSTEM_CONFIGURATION
),
629 FreePool (FakeNvData
);
631 DataSize
= sizeof(OsSelection
);
632 Status
= gRT
->GetVariable(
634 &gOsSelectionVariableGuid
,
640 if (EFI_ERROR(Status
) || (OsSelection
!= FakeNvData
->ReservedO
)) {
641 OsSelection
= FakeNvData
->ReservedO
;
642 Status
= gRT
->SetVariable (
644 &gOsSelectionVariableGuid
,
645 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
661 } else if ((KeyValue
== 0x123A) || (KeyValue
== 0x123B) || (KeyValue
== 0x123C)) {
662 StrCpy (StringBuffer1
, L
"WARNING: Enable or disable USB Controllers will ");
663 StrCpy (StringBuffer2
, L
"make global reset to restart system.");
664 StrCpy (StringBuffer3
, L
"Press Enter/ESC to continue...");
666 // Popup a menu to notice user
669 CreatePopUp (EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
, &Key
, StringBuffer1
, StringBuffer2
, StringBuffer3
, NULL
);
670 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
672 FakeNvData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
673 Status
= HiiGetBrowserData (
676 sizeof (SYSTEM_CONFIGURATION
),
682 SizeOfNvStore
= sizeof(SYSTEM_CONFIGURATION
);
683 SetupData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
684 Status
= gRT
->GetVariable(
691 if ((SetupData
->UsbAutoMode
!= FakeNvData
->UsbAutoMode
) ||
692 (SetupData
->UsbXhciSupport
!= FakeNvData
->UsbXhciSupport
) ||
693 (SetupData
->PchUsb20
!= FakeNvData
->PchUsb20
)) {
707 FreePool (StringBuffer1
);
708 FreePool (StringBuffer2
);
709 FreePool (StringBuffer3
);
712 // Workaround for Load Default for "DPTF Enable"
714 if (Action
== EFI_BROWSER_ACTION_DEFAULT_STANDARD
) {
715 if (KeyValue
== 0x1239) {
716 return EFI_NOT_FOUND
;
720 if (Action
== EFI_BROWSER_ACTION_FORM_CLOSE
) {
722 // Do nothing for UEFI OPEN/CLOSE Action
727 Private
= EFI_CALLBACK_INFO_FROM_THIS (This
);
728 FakeNvData
= &Private
->FakeNvData
;
729 if (!HiiGetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
)) {
730 return EFI_NOT_FOUND
;
733 if ((Action
== EFI_BROWSER_ACTION_FORM_OPEN
) && (Private
->FakeNvData
.ReservedO
!= Private
->BackupNvData
.ReservedO
)) {
734 Private
->BackupNvData
.ReservedO
= Private
->FakeNvData
.ReservedO
;
735 LoadLpssDefaultValues (Private
);
739 // When user selected the secure erase, set it to disable
741 if((KeyValue
== 0x1240) && (Action
== EFI_BROWSER_ACTION_CHANGED
)) {
742 FakeNvData
->SecureErase
= 0;
745 if ((Action
== EFI_BROWSER_ACTION_FORM_OPEN
) || (Action
== EFI_BROWSER_ACTION_CHANGED
)) {
747 // If function 0 is disabled, function 1 ~ 7 also required to be disabled.
749 if (Private
->FakeNvData
.LpssDma0Enabled
== 0) {
750 Private
->FakeNvData
.LpssHsuart0Enabled
= 0;
751 Private
->FakeNvData
.LpssHsuart1Enabled
= 0;
752 Private
->FakeNvData
.LpssPwm0Enabled
= 0;
753 Private
->FakeNvData
.LpssPwm1Enabled
= 0;
754 Private
->FakeNvData
.LpssSpiEnabled
= 0;
759 // If function 0 is disabled, function 1 ~ 7 also required to be disabled.
761 if (Private
->FakeNvData
.LpssDma1Enabled
== 0) {
762 Private
->FakeNvData
.LpssI2C0Enabled
= 0;
763 Private
->FakeNvData
.LpssI2C1Enabled
= 0;
764 Private
->FakeNvData
.LpssI2C2Enabled
= 0;
765 Private
->FakeNvData
.LpssI2C3Enabled
= 0;
766 Private
->FakeNvData
.LpssI2C4Enabled
= 0;
767 Private
->FakeNvData
.LpssI2C5Enabled
= 0;
768 Private
->FakeNvData
.LpssI2C6Enabled
= 0;
774 // Pass changed uncommitted data back to Form Browser
776 HiiSetBrowserData (&mSystemConfigGuid
, mVariableName
, sizeof (SYSTEM_CONFIGURATION
), (UINT8
*) FakeNvData
, NULL
);
783 The driver Entry Point. The function will export a disk device class formset and
784 its callback function to hii database.
786 @param ImageHandle The firmware allocated handle for the EFI image.
787 @param SystemTable A pointer to the EFI System Table.
789 @retval EFI_SUCCESS The entry point is executed successfully.
790 @retval other Some error occurs when executing this entry point.
795 PlatformSetupDxeInit (
796 IN EFI_HANDLE ImageHandle
,
797 IN EFI_SYSTEM_TABLE
*SystemTable
801 EFI_FORM_BROWSER2_PROTOCOL
*FormBrowser2
;
803 mImageHandle
= ImageHandle
;
806 // There should only be one Form Configuration protocol
808 Status
= gBS
->LocateProtocol (
809 &gEfiFormBrowser2ProtocolGuid
,
811 (VOID
**) &FormBrowser2
813 if (EFI_ERROR (Status
)) {
817 mCallbackInfo
= AllocateZeroPool (sizeof (EFI_CALLBACK_INFO
));
818 if (mCallbackInfo
== NULL
) {
819 return EFI_BAD_BUFFER_SIZE
;
822 mCallbackInfo
->Signature
= EFI_CALLBACK_INFO_SIGNATURE
;
823 mCallbackInfo
->ConfigAccess
.ExtractConfig
= SystemConfigExtractConfig
;
824 mCallbackInfo
->ConfigAccess
.RouteConfig
= SystemConfigRouteConfig
;
825 mCallbackInfo
->ConfigAccess
.Callback
= SystemConfigCallback
;
828 // Install Device Path Protocol and Config Access protocol to driver handle
829 // Install Platform Driver Override Protocol to driver handle
831 Status
= gBS
->InstallMultipleProtocolInterfaces (
832 &mCallbackInfo
->DriverHandle
,
833 &gEfiDevicePathProtocolGuid
,
834 &mHiiVendorDevicePath
,
835 &gEfiHiiConfigAccessProtocolGuid
,
836 &mCallbackInfo
->ConfigAccess
,
839 if (EFI_ERROR (Status
)) {
844 // Publish our HII data
846 mCallbackInfo
->RegisteredHandle
= HiiAddPackages (
848 mCallbackInfo
->DriverHandle
,
850 PlatformSetupDxeStrings
,
853 if (mCallbackInfo
->RegisteredHandle
== NULL
) {
854 Status
= EFI_OUT_OF_RESOURCES
;
858 mHiiHandle
= mCallbackInfo
->RegisteredHandle
;
861 // Locate ConfigRouting protocol
863 Status
= gBS
->LocateProtocol (
864 &gEfiHiiConfigRoutingProtocolGuid
,
866 (VOID
**) &mCallbackInfo
->HiiConfigRouting
868 if (EFI_ERROR (Status
)) {
873 // Clear all the globle variable
878 if (mCallbackInfo
->DriverHandle
!= NULL
) {
879 gBS
->UninstallMultipleProtocolInterfaces (
880 mCallbackInfo
->DriverHandle
,
881 &gEfiDevicePathProtocolGuid
,
882 &mHiiVendorDevicePath
,
883 &gEfiHiiConfigAccessProtocolGuid
,
884 &mCallbackInfo
->ConfigAccess
,
889 if (mCallbackInfo
->RegisteredHandle
!= NULL
) {
890 HiiRemovePackages (mCallbackInfo
->RegisteredHandle
);
893 if (mCallbackInfo
!= NULL
) {
894 FreePool (mCallbackInfo
);
901 Unload its installed protocol.
903 @param[in] ImageHandle Handle that identifies the image to be unloaded.
905 @retval EFI_SUCCESS The image has been unloaded.
909 PlatformSetupDxeUnload (
910 IN EFI_HANDLE ImageHandle
913 if (mCallbackInfo
!= NULL
) {
914 if (mCallbackInfo
->DriverHandle
!= NULL
) {
915 gBS
->UninstallMultipleProtocolInterfaces (
916 mCallbackInfo
->DriverHandle
,
917 &gEfiDevicePathProtocolGuid
,
918 &mHiiVendorDevicePath
,
919 &gEfiHiiConfigAccessProtocolGuid
,
920 &mCallbackInfo
->ConfigAccess
,
925 if (mCallbackInfo
->RegisteredHandle
!= NULL
) {
926 HiiRemovePackages (mCallbackInfo
->RegisteredHandle
);
929 FreePool (mCallbackInfo
);