diff options
Diffstat (limited to 'EDK/MiniSetup/uefi2.0')
-rw-r--r-- | EDK/MiniSetup/uefi2.0/FormBrowser.c | 591 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/Hiicallback.c | 429 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/Uefi20.cif | 16 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/ctrlcond.c | 840 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/ctrlcond.h | 113 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/hii.c | 3273 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/hii.h | 328 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/uefi20.mak | 128 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/uefi20.sdl | 53 | ||||
-rw-r--r-- | EDK/MiniSetup/uefi2.0/uefi20Wapper.c | 2428 |
10 files changed, 8199 insertions, 0 deletions
diff --git a/EDK/MiniSetup/uefi2.0/FormBrowser.c b/EDK/MiniSetup/uefi2.0/FormBrowser.c new file mode 100644 index 0000000..1c500a9 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/FormBrowser.c @@ -0,0 +1,591 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2012, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/FormBrowser.c $ +// +// $Author: Arunsb $ +// +// $Revision: 12 $ +// +// $Date: 10/18/12 6:00a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/FormBrowser.c $ +// +// 12 10/18/12 6:00a Arunsb +// Updated for 2.16.1235 QA submission +// +// 11 10/10/12 12:39p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 11 5/28/12 5:55a Premkumara +// [TAG] EIP75236 +// [Category] Improvement +// [Description] Add the support to control the GOP dependency in TSE +// notification. +// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h, +// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c +// +// 10 12/01/11 5:44a Rajashakerg +// [TAG] EIP74963 +// [Category] Improvement +// [Description] MAX_MSGBOX_WIDTH cannot be overridden +// [Files] AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c, +// MessageBox.c, MessageBox.h, FormBrowser.c +// +// 9 11/21/11 5:53a Rajashakerg +// [TAG] EIP74591 +// [Category] Improvement +// [Description] Make MainSetupLoop as board module hook +// [Files] AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h, +// FormBrowser.c, FormBrowser2.c +// +// 8 11/08/11 4:56a Rajashakerg +// Lowered the TPL to Application level and invoked +// StyleUpdateVersionString() function to update the copy right string in +// the SendForm() function. +// +// 7 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 9 8/13/10 10:14a Mallikarjunanv +// EIP-40056: Updated with the modified function call GetControlHeight +// +// 8 2/26/10 6:56p Madhans +// To validate the Hii Handle +// +// 6 2/19/10 8:20a Mallikarjunanv +// updated year in copyright message +// +// 5 1/27/10 12:59p Madhans +// // EIP 33804 : Issue iSCSI initiator name is not saved.. +// +// 4 1/09/10 7:31a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 3 6/23/09 6:51p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:08p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 4/28/09 9:40p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 3/31/09 4:14p Madhans +// UEFI Wrapper improvments. +// +// 1 2/06/09 4:10p Madhans +// FormBorwser protocol support added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +// +// +//*****************************************************************// +//*****************************************************************// + +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: FormBrowser.c +// +// Description: This file contains code for form browser +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "minisetup.h" + +#include EFI_PROTOCOL_DEFINITION(Hii) +#include EFI_PROTOCOL_DEFINITION(FormCallback) +extern EFI_HII_PROTOCOL *gHiiProtocol; + +#if SETUP_FORM_BROWSER_SUPPORT +EFI_STATUS +MinisetupSendForm ( + IN EFI_FORM_BROWSER_PROTOCOL * This, + IN BOOLEAN UseDatabase, + IN EFI_HII_HANDLE * Handle, + IN UINTN HandleCount, + IN EFI_IFR_PACKET * Packet, + IN EFI_HANDLE CallbackHandle, + IN UINT8 *NvMapOverride, + IN SCREEN_DESCRIPTOR * ScreenDimensions, + OUT BOOLEAN *ResetRequired + ); + +EFI_STATUS +MinisetupCreatePopup ( + IN UINTN NumberOfLines, + IN BOOLEAN HotKey, + IN UINTN MaximumStringSize, + OUT CHAR16 *StringBuffer, + OUT EFI_INPUT_KEY * KeyValue, + IN CHAR16 *String, + ... + ); + +EFI_FORM_BROWSER_PROTOCOL gFormBrowserProtocol = +{ + MinisetupSendForm, + MinisetupCreatePopup +}; + +VOID* *gSfHandles; +UINTN gSfHandleCount; +UINT8 *gSfNvMap; + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MinisetupSendForm +// +// Description: Function implements the SendForm interface of Formbrowser +// Protocol. UseDatabase=True is only supported. +// +// Input: Refer Spec. Packet,CallbackHandle, ScreenDimensions and ResetRequired +// parameters ignored. +// +// IN EFI_FORM_BROWSER_PROTOCOL * This, +// IN BOOLEAN UseDatabase, +// IN EFI_HII_HANDLE * Handle, +// IN UINTN HandleCount, +// IN EFI_IFR_PACKET * Packet, +// IN EFI_HANDLE CallbackHandle, +// IN UINT8 *NvMapOverride, +// IN SCREEN_DESCRIPTOR * ScreenDimensions, +// OUT BOOLEAN *ResetRequired +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +MinisetupSendForm ( + IN EFI_FORM_BROWSER_PROTOCOL * This, + IN BOOLEAN UseDatabase, + IN EFI_HII_HANDLE * Handles, + IN UINTN HandleCount, + IN EFI_IFR_PACKET * Packet, + IN EFI_HANDLE CallbackHandle, + IN UINT8 *NvMapOverride, + IN SCREEN_DESCRIPTOR * ScreenDimensions, + OUT BOOLEAN *ResetRequired + ) +{ + EFI_STATUS Status = EFI_SUCCESS; + UINTN i; + if(UseDatabase) + { + if( Handles == NULL || HandleCount == 0 ) + { + return EFI_INVALID_PARAMETER; + } + +#ifndef STANDALONE_APPLICATION + if ( ! gConsoleControl ) + { + //All necessary protocols are not available yet. + //We can still proceed if Uga Draw is the only protocol not available yet. + ActivateApplication(); + + if (!IsDelayLogoTillInputSupported()) //EIP-75236 + ActivateInput(); + } +#endif + + //Initialize send form global variables + if(HandleCount) + { + gSfHandles = EfiLibAllocateZeroPool( HandleCount * sizeof(VOID*)); + gSfHandleCount = 0; + for(i=0;i<HandleCount;i++) + { + UINT8 *FormSet = NULL; + UINTN Length = 0; + // Check if the Handle Has Forms to Display + FormSet = _HiiGetForm( (VOID*)Handles[i], 0, &Length); + if( FormSet != NULL ) + { + gSfHandles[gSfHandleCount] = (VOID*)(UINTN)Handles[i]; + MemFreePointer( &FormSet ); + gSfHandleCount++; + } + } + if( gSfHandleCount == 0 ) + { + MemFreePointer( (VOID**)&gSfHandles ); + return EFI_NOT_FOUND; + } + } + + + gSfNvMap = NvMapOverride; + + if(!gVariableList) + VarLoadVariables( (VOID **)&gVariableList, NULL ); + + // this *MUST* be run a EFI_TPL_APPLICATION + gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); // guarantees that RestoreTPL won't ASSERT + gBS->RestoreTPL( EFI_TPL_APPLICATION ); + + StyleUpdateVersionString(); + + //Show forms + Status = gST->ConIn->Reset( gST->ConIn, FALSE ); + Status = MainSetupLoopHook();//EIP74591 : Modified MainSetupLoop as board module hook + + //Reset send form global variables + MemFreePointer( (VOID**)&gSfHandles ); + gSfHandles = NULL; + + gSfHandleCount = 0; + gSfNvMap = NULL; + + return Status; + } + else + { + return EFI_UNSUPPORTED; + } +} + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MinisetupCreatePopup +// +// Description: Function implements the CreatePopup interface of Formbrowser +// Protocol. +// +// Input: +// IN UINTN NumberOfLines, +// IN BOOLEAN HotKey, +// IN UINTN MaximumStringSize, +// OUT CHAR16 *StringBuffer, +// OUT EFI_INPUT_KEY * KeyValue, +// IN CHAR16 *String, +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +MinisetupCreatePopup ( + IN UINTN NumberOfLines, + IN BOOLEAN HotKey, + IN UINTN MaximumStringSize, + OUT CHAR16 *StringBuffer, + OUT EFI_INPUT_KEY * KeyValue, + IN CHAR16 *String, + ... + ) +{ + VA_LIST Marker; + MEMO_DATA **memo; + POPUP_DATA *popup = NULL; + CONTROL_INFO dummy; + AMI_IFR_MSGBOX MsgData; + VOID *ScreenBuf; + UINT16 *textToken; + UINT16 Height =0 ; + EFI_IFR_SUBTITLE *buff; + CONTROL_INFO *MemoCtrlData; + EFI_STATUS Status; + UINTN i; + CONTROL_ACTION MappedAction = ControlActionUnknown; + UINTN StrIndex = 0; + EFI_INPUT_KEY Key; + CHAR16 *EditString; + + if (HotKey) + { + if (KeyValue == NULL) + { + return EFI_INVALID_PARAMETER; + } + } + else + { + if (StringBuffer == NULL) + { + return EFI_INVALID_PARAMETER; + } + } + + //Put strings in Hii + VA_START (Marker, String); + textToken = EfiLibAllocateZeroPool(NumberOfLines*sizeof(UINT16)); + i=0; + textToken[i] = HiiChangeString(gHiiHandle, textToken[i], String); + i++; + for(;i<NumberOfLines; i++) + { + textToken[i] = HiiChangeString(gHiiHandle, textToken[i], VA_ARG (Marker, CHAR16 *)); + } + + //Create + gPopup.Create(&popup); + + //Init + MemSet( &dummy, sizeof(dummy), 0 ); + dummy.ControlHandle = INVALID_HANDLE; + + MsgData.Opcode = 0; + MsgData.Length = 0; + MsgData.Title = 0; + MsgData.TextHandle = INVALID_HANDLE; + MsgData.Text = 0; + + dummy.ControlPtr = (VOID*) (&MsgData); + dummy.ControlFlags.ControlVisible = TRUE; + + Status = gPopup.Initialize( popup, &dummy ); + if (EFI_ERROR(Status)) + return Status; + + // To fix the Color of the popup Box. + SetControlColorsHook( NULL, NULL, NULL , NULL, NULL , NULL, NULL , + NULL , NULL, NULL,NULL , + NULL,NULL ,&(popup->FGColor),&(popup->BGColor) ); + + popup->Container = NULL; + popup->Border =TRUE; + popup->Width = GetMsgboxWidth(); //EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary + popup->Height = 4; + + MemoCtrlData = EfiLibAllocateZeroPool(NumberOfLines*sizeof(CONTROL_INFO)); + memo = EfiLibAllocateZeroPool(NumberOfLines*sizeof(MEMO_DATA *)); + for(i=0;i<NumberOfLines;i++) + { + gMemo.Create(&(memo[i])); + buff = EfiLibAllocateZeroPool(sizeof(EFI_IFR_SUBTITLE)); + buff->Header.OpCode = EFI_IFR_SUBTITLE_OP ; + buff->Header.Length = sizeof(EFI_IFR_SUBTITLE) ; + buff->SubTitle= textToken[i]; + MemoCtrlData[i].ControlPtr = (VOID*)buff; + MemoCtrlData[i].ControlHandle = INVALID_HANDLE; + MemoCtrlData[i].ControlFlags.ControlVisible = TRUE; + gMemo.Initialize(memo[i],(VOID *)&(MemoCtrlData[i])); + memo[i]->Width = popup->Width - 2; +//EIP:40056 - START +//Updated with the modified function + // gMemo.GetTextHeight( memo[i], &Height ); + gMemo.GetControlHeight( memo[i], NULL, &Height ); +//EIP:40056 - END + popup->Height = popup->Height + Height; + gMemo.SetAttributes(memo[i],popup->FGColor ,popup->BGColor); + gMemo.SetDimensions( memo[i], popup->Width-2 , Height ); + gMemo.SetJustify( memo[i], JUSTIFY_CENTER ); + } + + + //Draw + ScreenBuf = SaveScreen(); + Status = gPopup.Draw( popup ); + if(EFI_ERROR(Status)) + return Status; + Height = popup->Top + 2; + for(i=0;i<NumberOfLines;i++) + { + gMemo.SetPosition( memo[i], popup->Left + 1, Height); + gMemo.Draw( memo[i] ); + Height = Height + memo[i]->Height; + } + + FlushLines( popup->Top, popup->Top + popup->Height ); + DoRealFlushLines(); + + //Getkeys + gST->ConIn->Reset( gST->ConIn, FALSE ); + EditString = EfiLibAllocateZeroPool(MaximumStringSize); + while( + (MappedAction != ControlActionSelect) && + (MappedAction != ControlActionAbort) + ) + { + if(EFI_SUCCESS == gST->ConIn->ReadKeyStroke( gST->ConIn, &Key )) + { + AMI_EFI_KEY_DATA AmiKey; + AmiKey.Key = Key; + MappedAction = MapControlKeysHook(AmiKey); + + if(HotKey) + { + *KeyValue = Key; + break; + } + else + { + if((ControlActionAlpha == MappedAction) || (ControlActionNumeric == MappedAction)) + { + if(StrIndex < (MaximumStringSize/2)) + { + EditString[StrIndex] = Key.UnicodeChar; + StrIndex++; + } + } + } + } + } + + if(MappedAction == ControlActionSelect && !HotKey) + { + MemCopy(StringBuffer, EditString, MaximumStringSize); + } + + //Destroy + Status = gPopup.Destroy( popup, TRUE ); + MemFreePointer( (VOID **)&(textToken) ); + for(i=0;i<NumberOfLines;i++) + { + MemFreePointer( (VOID **)&(memo[i]->ControlData.ControlPtr) ); + Status = gMemo.Destroy( memo[i], TRUE ); + } + MemFreePointer( (VOID **)&(MemoCtrlData) ); + MemFreePointer( (VOID **)&(memo) ); + MemFreePointer( (VOID **)&(EditString) ); + + RestoreScreen( ScreenBuf ); + + //Return + return EFI_SUCCESS; +} +#endif //#if SETUP_FORM_BROWSER_SUPPORT + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: InstallFormBrowserProtocol +// +// Description: Installs the Formbrowser Protocol in the given handle if +// SETUP_FORM_BROWSER_SUPPORT is on. +// +// Input: IN EFI_HANDLE Handle +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS InstallFormBrowserProtocol(EFI_HANDLE Handle) +{ +#if SETUP_FORM_BROWSER_SUPPORT + EFI_STATUS Status; + Status = gBS->InstallMultipleProtocolInterfaces( + &Handle, + &gEfiFormBrowserProtocolGuid, &gFormBrowserProtocol, + NULL + ); + return Status; +#else + return EFI_SUCCESS; +#endif //#if SETUP_FORM_BROWSER_SUPPORT +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UnInstallFormBrowserProtocol +// +// Description: Uninstalls the Formbrowser Protocol in the given handle if +// SETUP_FORM_BROWSER_SUPPORT is on. +// +// Input: IN EFI_HANDLE Handle +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle) +{ +#if SETUP_FORM_BROWSER_SUPPORT + gBS->UninstallMultipleProtocolInterfaces( + &Handle, + &gEfiFormBrowserProtocolGuid, &gFormBrowserProtocol, + NULL + ); +#endif //#if SETUP_FORM_BROWSER_SUPPORT +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: FormBrowserHandleValid +// +// Description: return True Browser is showing forms from SendForm interface. +// +// Input: none +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN FormBrowserHandleValid(VOID) +{ +#if SETUP_FORM_BROWSER_SUPPORT + if(gSfHandles) + return TRUE; +#endif + return FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: FormBrowserLocateSetupHandles +// +// Description: return Handles and count that is passed to SendForm interface. +// +// Input: OUT handleBuffer and count +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS FormBrowserLocateSetupHandles(VOID* **handleBuffer,UINT16 *count) +{ +#if SETUP_FORM_BROWSER_SUPPORT + if(gSfHandles) + { + *handleBuffer = (VOID**)gSfHandles; + *count = (UINT16)gSfHandleCount; + return EFI_SUCCESS; + } + else + return EFI_NOT_FOUND; +#else + return EFI_UNSUPPORTED; +#endif +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/uefi2.0/Hiicallback.c b/EDK/MiniSetup/uefi2.0/Hiicallback.c new file mode 100644 index 0000000..efdbaf8 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/Hiicallback.c @@ -0,0 +1,429 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/Hiicallback.c $ +// +// $Author: Premkumara $ +// +// $Revision: 11 $ +// +// $Date: 3/25/13 8:35a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/Hiicallback.c $ +// +// 11 3/25/13 8:35a Premkumara +// [TAG] EIP116315 +// [Category] Improvement +// [Description] Display control prompt string for password control. +// (for String on CHAP secret popup) +// [Files] - AMITSE.sdl +// - CommonHelper.c +// - FakeToken.c +// - AmiTSEStr.uni +// - TseLite\PopupPassword.c +// - uefi2.1\UefiWapper21.c +// - uefi2.0\HiiCallback.c +// - uefi2.0\hii.h +// - uefi2.0\hii.c +// +// 10 10/18/12 6:00a Arunsb +// Updated for 2.16.1235 QA submission +// +// 9 10/10/12 12:39p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 9 1/09/12 1:53a Arunsb +// [TAG] EIP79952 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Add driver option displays select boot option as title +// [RootCause] Title problem +// [Solution] Title changes +// [Files] Faketokens.c, amitsestr.uni, addbootoption.c, +// uefi2.0\hiicallback.c and uefi21wapper.c +// +// 8 12/02/11 1:51a Premkumara +// [TAG] EIP73226 +// [Category] New Feature +// [Description] Extended support for password prompt +// [Files] FakeToken.c, Uefi21Wapper.c, AmiTSEStr.uni, PopupPassword.c, +// HiiCallback.c, Uefi20Wapper.c +// +// 7 5/02/11 9:56a Arunsb +// [TAG] EIP58126 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] System boot into setup page, it will popup "ME Update Info" +// [RootCause] Different actions allowed in 2.0 version also +// [Solution] Only update action is handled in 2.0 version +// [Files] uefi2.0\Hiicallback.c, uefi2.1\Hiicallback.c, Commonhelper.c +// +// 6 3/21/11 12:52a Rajashakerg +// [TAG] EIP53480 +// [Category] Improvement +// [Description] FormBrowser extended actions support +// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c, +// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c, +// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c +// +// 5 2/19/10 1:04p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 7 2/19/10 8:20a Mallikarjunanv +// updated year in copyright message +// +// 6 1/09/10 7:27a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 5 1/04/10 10:40a Mallikarjunanv +// EIPs 27161/29095 - Added support for reserved boot option names and +// added support not to create empty boot option names +// +// 4 6/24/09 6:11p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:51p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 2 5/07/09 10:36a Madhans +// Changes after Bin module +// +// 1 4/28/09 11:09p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:40p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:14p Madhans +// UEFI Wrapper improvments. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +// +// +//*****************************************************************// +//*****************************************************************// + +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: HiiCallback.c +// +// Description: This file contains code for Hii callback operations +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "minisetup.h" +#include EFI_PROTOCOL_DEFINITION(Hii) +#include EFI_PROTOCOL_DEFINITION(FormCallback) +extern EFI_HII_PROTOCOL *gHiiProtocol; + + +static STRING_REF CallbackErrToken=0; + +AMI_IFR_MSGBOX _PreviousMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_PREVIOUS), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_PREVIOUS_MSG) }; +AMI_IFR_MSGBOX _FailsafeMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_FAILSAFE), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_FAILSAFE_MSG) }; +AMI_IFR_MSGBOX _OptimalMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_OPTIMAL), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_OPTIMAL_MSG) }; +AMI_IFR_MSGBOX _SaveMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_VALUES), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_VALUES_MSG) }; +AMI_IFR_MSGBOX _SaveExitMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_EXIT), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_EXIT_MSG) }; +AMI_IFR_MSGBOX _ExitMsgBox = { 0, 0, STRING_TOKEN(STR_EXIT), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_EXIT_MSG) }; +AMI_IFR_MSGBOX _SaveResetMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_RESET), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_RESET_MSG) }; +AMI_IFR_MSGBOX _ResetMsgBox = { 0, 0, STRING_TOKEN(STR_RESET), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_RESET_MSG) }; +AMI_IFR_MSGBOX _HelpMsgBox = { 0, 0, STRING_TOKEN(STR_GENERAL_HELP), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_GENERAL_HELP_MSG) }; +AMI_IFR_MSGBOX _SaveUserMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_USER_DEFAULTS), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_VALUES_MSG) }; +AMI_IFR_MSGBOX _LoadUserMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_USER_DEFAULTS), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_USER_MSG) }; + +AMI_IFR_MSGBOX _InvalidPasswordFailMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR),(VOID*)(UINTN) INVALID_HANDLE, STRING_TOKEN(STR_ERROR_PSWD) }; +AMI_IFR_MSGBOX _ClearPasswordMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING),(VOID*) INVALID_HANDLE, STRING_TOKEN(STR_PSWD_CLR) };//EIP:73226 To Clear Old Password message +AMI_IFR_MSGBOX _ClearPasswordLabelMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING),(VOID*) INVALID_HANDLE, STRING_TOKEN(STR_PSWD_CLR_LABEL) };//EIP:73226 To Clear Old Password message +AMI_IFR_MSGBOX _BootLaunchFailedMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_WARNING_NOT_FOUND) }; + +AMI_IFR_MSGBOX _gInvalidRangeFailMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR), INVALID_HANDLE, STRING_TOKEN(STR_ERROR_INPUT) }; + +AMI_IFR_MSGBOX _gDelBootOptionReserved = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_DEL_BOOT_OPTION_RESERVED) }; +AMI_IFR_MSGBOX _gAddBootOptionReserved = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_BOOT_OPTION_RESERVED) }; +AMI_IFR_MSGBOX _gAddBootOptionEmpty = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_BOOT_OPTION_EMPTY) }; +AMI_IFR_MSGBOX _gAddDriverOptionEmpty = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_DRIVER_OPTION_EMPTY) }; + +UINTN gPreviousMsgBox = (UINTN)&_PreviousMsgBox; +UINTN gFailsafeMsgBox = (UINTN)&_FailsafeMsgBox; +UINTN gOptimalMsgBox = (UINTN)&_OptimalMsgBox; +UINTN gSaveMsgBox = (UINTN)&_SaveMsgBox; +UINTN gSaveExitMsgBox = (UINTN)&_SaveExitMsgBox; +UINTN gExitMsgBox = (UINTN)&_ExitMsgBox; +UINTN gSaveResetMsgBox = (UINTN)&_SaveResetMsgBox; +UINTN gResetMsgBox = (UINTN)&_ResetMsgBox; +UINTN gHelpMsgBox = (UINTN)&_HelpMsgBox; +UINTN gSaveUserMsgBox = (UINTN)&_SaveUserMsgBox; +UINTN gLoadUserMsgBox = (UINTN)&_LoadUserMsgBox; +UINTN gBootLaunchFailedMsgBox = (UINTN)&_BootLaunchFailedMsgBox; +UINTN gInvalidPasswordFailMsgBox=(UINTN)&_InvalidPasswordFailMsgBox; +UINTN gClearPasswordMsgBox=(UINTN)&_ClearPasswordMsgBox;//EIP:73226 To display Clear Old Password message +UINTN gClearLabelPasswordMsgBox = (UINTN)&_ClearPasswordLabelMsgBox; +UINTN gInvalidRangeFailMsgBox=(UINTN)&_gInvalidRangeFailMsgBox; +UINTN gDelBootOptionReserved = (UINTN)&_gDelBootOptionReserved; +UINTN gAddBootOptionReserved = (UINTN)&_gAddBootOptionReserved; +UINTN gAddBootOptionEmpty = (UINTN)&_gAddBootOptionEmpty; +UINTN gAddDriverOptionEmpty = (UINTN)&_gAddDriverOptionEmpty; + +static AMI_IFR_MSGBOX gCallbackErrorMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR), (VOID*)(UINTN)INVALID_HANDLE, 0 }; +EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle ); +EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index ); + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CallFormCallBack +// +// Description: To call form callback +// +// Input: CONTROL_INFO * pControlData, +// UINT16 Key, +// UINT8 Flags +// UINTN Action +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS CallFormCallBack(CONTROL_INFO * pControlData,UINT16 Key,UINT8 Flags,UINTN Action)//EIP-53480: Implementation of FormBrowser with actions support +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL; + EFI_IFR_FORM_SET *FormSet = NULL; + EFI_IFR_DATA_ARRAY * callbackData = NULL; + EFI_HII_CALLBACK_PACKET *Packet =NULL ; + UINTN Size; + + if (AMI_CALLBACK_CONTROL_UPDATE != Action) + { + return EFI_UNSUPPORTED; + } + FormSet = HiiGetFormSetFromHandle( pControlData->ControlHandle );//HiiGetFormSet( 0 ); + + callbackData = EfiLibAllocateZeroPool( 0x10000 ); + if(callbackData == NULL) + return EFI_OUT_OF_RESOURCES; + + callbackData->NvRamMap = gVariableList[ pControlData->ControlVariable ].Buffer; + + + if ( FormSet != NULL ) + { + callbackData->EntryCount = 1; + ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->OpCode = ((EFI_IFR_OP_HEADER *)(pControlData->ControlPtr))->OpCode; + switch(((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->OpCode) + { + case EFI_IFR_STRING_OP: + Size = ((EFI_IFR_STRING *)(pControlData->ControlPtr))->MaxSize * 2; + ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8)Size + 4; + MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_STRING *)(pControlData->ControlPtr))->QuestionId,Size); + break; + case EFI_IFR_NUMERIC_OP: + Size = ((EFI_IFR_NUMERIC *)(pControlData->ControlPtr))->Width; + ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8) Size + 4; + MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_NUMERIC *)(pControlData->ControlPtr))->QuestionId,Size); + break; + case EFI_IFR_REF_OP: + ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = 6; + MemCopy(&(callbackData->Data[0].Data),&((EFI_IFR_REF *)(pControlData->ControlPtr))->FormId,2); + break; + case EFI_IFR_ONE_OF_OP: + Size = ((EFI_IFR_ONE_OF *)(pControlData->ControlPtr))->Width; + ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8) Size + 4; + MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_ONE_OF *)(pControlData->ControlPtr))->QuestionId,Size); + break; + //EIP-16541 : for EFIMEBX checkbox call back handle. + case EFI_IFR_CHECKBOX_OP: + Size = ((EFI_IFR_CHECK_BOX *)(pControlData->ControlPtr))->Width; + ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8) Size + 4; + MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_CHECK_BOX *)(pControlData->ControlPtr))->QuestionId,Size); + break; + default: + callbackData->EntryCount=0; + } + + Status = gBS->HandleProtocol ( (EFI_HANDLE)((UINTN) FormSet->CallbackHandle), &gEfiFormCallbackProtocolGuid, &FormCallBack); + + + if ( ( FormCallBack != NULL ) && ( FormCallBack->Callback != NULL ) ) + Status = FormCallBack->Callback( FormCallBack, Key, callbackData, &Packet ); + + + if(EFI_ERROR(Status)) + if(Packet != NULL) + { + if(Packet->String!=NULL) + { EFI_STATUS Sts; + Sts = gHiiProtocol->NewString(gHiiProtocol,NULL,(EFI_HII_HANDLE)(UINTN)gHiiHandle,&CallbackErrToken, Packet->String); + gCallbackErrorMsgBox.Text=CallbackErrToken; + if(!EFI_ERROR(Sts)) + CallbackShowMessageBox( (UINTN)&gCallbackErrorMsgBox, MSGBOX_TYPE_OK ); + } + MemFreePointer( (VOID *)&Packet); + } + } + + MemFreePointer( (VOID *)&callbackData); + return Status; +} + +#if !TSE_USE_EDK_LIBRARY + +#pragma pack(1) +typedef struct { + UINT8 OpCode; // Likely a string, numeric, or one-of + UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet + UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback + VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately + // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value + // If the OpCode is a String type - Data is a CHAR16[x] type + // If the OpCode is a Checkbox type - Data is a UINT8 value + // If the OpCode is a NV Access type - Data is a EFI_IFR_NV_DATA structure + // +} TSE_EFI_IFR_DATA_ENTRY; + +typedef struct { + VOID *NvRamMap; // If the flag of the op-code specified retrieval of a copy of the NVRAM map, + // this is a pointer to a buffer copy + // + UINT32 EntryCount; // How many EFI_IFR_DATA_ENTRY entries + TSE_EFI_IFR_DATA_ENTRY Data[1]; // The in-line Data entries. +} TSE_EFI_IFR_DATA_ARRAY; + +#pragma pack() +#else +#define TSE_EFI_IFR_DATA_ARRAY EFI_IFR_DATA_ARRAY +#endif // TSE_USE_EDK_LIBRARY + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CallTextCallBack +// +// Description: Fuction to call text callback +// +// Input: TEXT_DATA *text, ACTION_DATA *Data +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS CallTextCallBack(TEXT_DATA *text, ACTION_DATA *Data) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + + if ( --(text->Interval) == 0 ) + { + EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL; + EFI_IFR_FORM_SET *FormSet = NULL; + EFI_IFR_TEXT *ifrPtr; + TSE_EFI_IFR_DATA_ARRAY callbackData; + UINT16 DataArray[2]; + EFI_HII_CALLBACK_PACKET *Packet =NULL ; + + // initialize the interval + text->Interval = (UINT8)(text->ControlData.ControlFlags.ControlRefresh); + if ( text->Callback ) + text->Callback( text->Container, text, text->Cookie ); + + MemSet( &callbackData, sizeof(callbackData), 0 ); + ifrPtr = (EFI_IFR_TEXT *)text->ControlData.ControlPtr; + if ( ifrPtr->Flags & EFI_IFR_FLAG_NV_ACCESS ) + callbackData.NvRamMap = gVariableList[ text->ControlData.ControlVariable ].Buffer; + + callbackData.EntryCount = 1; + // token number of string to update + DataArray[0] = (UINT16)(UINTN)text->ControlData.ControlHandle; + DataArray[1] = ifrPtr->TextTwo; + callbackData.Data[0].Data = DataArray; + + FormSet = HiiGetFormSetFromHandle( text->ControlData.ControlHandle );//HiiGetFormSet( 0 ); + + if ( FormSet != NULL ) + { + Status = gBS->HandleProtocol ( (EFI_HANDLE)((UINTN) FormSet->CallbackHandle), &gEfiFormCallbackProtocolGuid, &FormCallBack); + + if ( ( FormCallBack != NULL ) && ( FormCallBack->Callback != NULL ) ) + Status = FormCallBack->Callback( FormCallBack, ifrPtr->Key, (EFI_IFR_DATA_ARRAY*)&callbackData, &Packet/*NULL*/ ); + + } + + return EFI_SUCCESS; + } + return EFI_UNSUPPORTED; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SpecialActionCallBack +// +// Description: Callback for UEFI Action control. This is used only in UEFI 2.1 +// +// Input: CONTROL_INFO * ControlData, UINT16 Key +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS SpecialActionCallBack(CONTROL_INFO * ControlData, UINT16 Key) +{ + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UEFICallSetupFormCallBack +// +// Description: Wrapper function for the Implementation of FormBrowser with actions support .This is used only in UEFI 2.1 +// +// Input: UINTN Action +// +// Output: VOID +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UEFICallSetupFormCallBack(UINTN Action ) +{//EIP-53480: Implementation of FormBrowser with actions support + +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/uefi2.0/Uefi20.cif b/EDK/MiniSetup/uefi2.0/Uefi20.cif new file mode 100644 index 0000000..05cd078 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/Uefi20.cif @@ -0,0 +1,16 @@ +<component> + name = "TSE Sources - UEFI2.0" + category = ModulePart + LocalRoot = "EDK\MiniSetup\uefi2.0" + RefName = "Uefi20" +[files] +"uefi20.sdl" +"uefi20.mak" +"hii.h" +"hii.c" +"ctrlcond.h" +"ctrlcond.c" +"Hiicallback.c" +"uefi20Wapper.c" +"FormBrowser.c" +<endComponent> diff --git a/EDK/MiniSetup/uefi2.0/ctrlcond.c b/EDK/MiniSetup/uefi2.0/ctrlcond.c new file mode 100644 index 0000000..fd962fa --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/ctrlcond.c @@ -0,0 +1,840 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.c $ +// +// $Author: Arunsb $ +// +// $Revision: 10 $ +// +// $Date: 10/18/12 6:00a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.c $ +// +// 10 10/18/12 6:00a Arunsb +// Updated for 2.16.1235 QA submission +// +// 9 10/10/12 12:39p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 9 11/01/11 10:54a Madhans +// [TAG] EIP51899 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Some Condition evaluation is broken. +// [RootCause] VAREQVAL is considering all the variable's size as UINTN. +// [Solution] It should based on the size of Variable. +// [Files] ctrlcond.c +// +// 8 3/29/11 1:15p Madhans +// [TAG] EIP56414 +// [Category] Improvement +// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode +// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c, +// CtrlCond.h, ctrlcond.h, ctrlcond.c +// +// 7 3/29/11 1:11p Madhans +// [TAG] EIP56414 +// [Category] Improvement +// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode +// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c, +// CtrlCond.h, ctrlcond.h, ctrlcond.c +// +// 6 3/23/10 3:39p Blaines +// EIP-36010 +// +// Fix for suppressif used with grayout condition. +// +// +// 5 2/19/10 1:04p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 6 2/19/10 8:20a Mallikarjunanv +// updated year in copyright message +// +// 5 1/09/10 7:26a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 4 6/24/09 6:11p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:51p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:08p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:40p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:14p Madhans +// UEFI Wrapper improvments. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: ctrlcond.c +// +// Description: This file contains code for control conditions +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "minisetup.h" +#include "ctrlcond.h" +#include EFI_PROTOCOL_DEFINITION(Hii) +#include EFI_PROTOCOL_DEFINITION(FormCallback) +extern EFI_HII_PROTOCOL *gHiiProtocol; + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetVarNumFromID +// +// Description: To get var number from ID +// +// Input: unsigned int ID +// +// Output: VarCount +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +int GetVarNumFromID(unsigned int ID) +{ + unsigned int i=0; + + while( ( ((VARIABLE_INFO *)((UINT8 *)gVariables + gVariables->VariableList[i]))->VariableID != ID) && (i < gVariables->VariableCount)) + i++; + + return i; + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CheckControlAccess +// +// Description: To check control flags +// +// Input: UINT32 ControlAccess +// +// Output: Condition +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 CheckControlAccess(UINT32 ControlAccess) +{ + UINT8 Cond = COND_NONE; + + if(gPasswordType == AMI_PASSWORD_USER) + { + switch(ControlAccess) + { + case CONTROL_ACCESS_ADMIN: // suppress + Cond = COND_SUPPRESS; + break; + case CONTROL_ACCESS_USER: // grayout (read-only) + Cond = COND_GRAYOUT; + break; + default: + break; + } + } + + return Cond; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UpdateFinalCondition +// +// Description: To finalize the codition flag +// +// Input: UINT8 FinalCond, UINT8 Cond +// +// Output: Condition +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 UpdateFinalCondition(UINT8 FinalCond, UINT8 Cond) +{ + switch(FinalCond) + { + case COND_NONE: + return(Cond); + break; + + case COND_SUPPRESS: + case COND_HIDDEN: + return(FinalCond); + break; + + case COND_GRAYOUT: + if(Cond != COND_NONE) + return(Cond); + break; + + case COND_INCONSISTENT: + return(Cond); + break; + + } + return(FinalCond); +} +//check condition +#if TSE_SUPPORT_VFRCOMPILE_1_88 + +static UINT8 Operands[10], StackPos; + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: EvaluateOpcode +// +// Description: To perform the stack operations based on the opcode +// +// Input: UINT8 OpCode +// +// Output: void +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID EvaluateOpcode(UINT8 OpCode) +{ + switch(OpCode) + { + case EFI_IFR_NOT_OP: + if(StackPos >= 1) //atleast one operand should be there + { + Operands[StackPos-1] = (Operands[StackPos-1] == 0) ? 1:0; + //No need to change the stack position because the + //result goes in the operands position + } + break; + case EFI_IFR_AND_OP: + if(StackPos >= 2)//atleast two oprerands should be there + { + Operands[StackPos-2] &= (Operands[StackPos-1]); + //Move stack position only one down. Result takes the + //second operands position + StackPos--; + } + break; + case EFI_IFR_OR_OP: + if(StackPos >= 2)//atleast two oprerands should be there + { + Operands[StackPos-2] |= (Operands[StackPos-1]); + //Move stack position only one down. Result takes the + //second operands position + StackPos--; + } + break; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetExpResult +// +// Description: Function to get exp result +// +// Input: nil +// +// Output: result +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 GetExpResult() +{ + UINT8 result = 0; + + if(StackPos) + { + if(StackPos == 1) + { + result = Operands[0]; + } + else + { + //Error condition!!! + } + } + + StackPos = 0; + + return result; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CheckControlCondition +// +// Description: This function eveluates the condition and retuns the result +// +// Input: Control Info +// +// Output: COND_NONE - Condition failed. +// COND_SUPPRESS - Condition matchs suppress +// COND_GRAYOUT - Condition matchs Grayout +// COND_HIDDEN - Condition matchs and Hide +// COND_INCONSISTENT - Inconsistent Condition matchs +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 CheckControlCondition( CONTROL_INFO *controlInfo ) +{ + // Used to be a long list of parameters + UINT32 CtrlAccess; + UINT8 *CondPtr; + UINT32 i=0; + UINT32 VarId1, VarId2; + UINT8 Cond = COND_NONE, FinalCond = COND_NONE; + + UINT32 Val1 = 0, Val2 = 0; + BOOLEAN Inside = TRUE; + + EFI_IFR_EQ_ID_VAL *IDValPtr; + EFI_IFR_EQ_ID_LIST *IDListPtr; + EFI_IFR_EQ_VAR_VAL *VarValPtr; + EFI_IFR_EQ_ID_ID *IDIDPtr; + + CondPtr = (UINT8 *)controlInfo->ControlConditionalPtr; + CtrlAccess = controlInfo->ControlFlags.ControlAccess; + + if ( CondPtr == NULL ) + return ( CheckControlAccess(CtrlAccess) ); + + VarId1 = controlInfo->ControlConditionalVariable[0]; + VarId2 = controlInfo->ControlConditionalVariable[1]; + + + while( Inside ) + { + switch(*(CondPtr+i)) + { + case EFI_IFR_SUPPRESS_IF_OP: + if(GetExpResult()) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + } + Cond = COND_SUPPRESS; + break; + + case EFI_IFR_GRAYOUT_IF_OP: + if(GetExpResult()) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + } + Cond = COND_GRAYOUT; + break; + + case EFI_IFR_HIDDEN_OP: + if(GetExpResult()) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + } + Cond = COND_HIDDEN; + break; + + case EFI_IFR_INCONSISTENT_IF_OP: + if(GetExpResult()) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + } + Cond = COND_INCONSISTENT; + break; + + case EFI_IFR_NOT_OP: + case EFI_IFR_AND_OP: + case EFI_IFR_OR_OP: + EvaluateOpcode(*(CondPtr+i)); + break; + + case EFI_IFR_EQ_ID_VAL_OP: + IDValPtr = (VOID*)(CondPtr+i); +//EIP:36010 - Start + Val1 = 0; +//EIP:36010 - End + VarGetValue( VarId1, IDValPtr->QuestionId, IDValPtr->Width, &Val1 ); + Operands[StackPos] = ( (UINT16)Val1 == IDValPtr->Value ) ? 1 : 0 ; + StackPos++; + break; + + case EFI_IFR_EQ_ID_LIST_OP: + IDListPtr = (VOID*)(CondPtr+i); +//EIP:36010 - Start + Val1 =0; +//EIP:36010 - End + VarGetValue( VarId1, IDListPtr->QuestionId, IDListPtr->Width, &Val1 ); + for ( Val2 = 0; Val2 < IDListPtr->ListLength; Val2++ ) + { + if ( IDListPtr->ValueList[Val2] == Val1 ) + { + Operands[StackPos] = 1;//Found a match in the list + break; + } + } + if(Val2 >= IDListPtr->ListLength)//Did not find a match + Operands[StackPos] = 0; + StackPos++; + break; + + case EFI_IFR_EQ_ID_ID_OP: + IDIDPtr = (VOID*)(CondPtr+i); +//EIP:36010 - Start + Val1 =0; + Val2 =0; +//EIP:36010 - End + VarGetValue( VarId1, IDIDPtr->QuestionId1, IDIDPtr->Width, &Val1 ); + VarGetValue( VarId2, IDIDPtr->QuestionId2, IDIDPtr->Width, &Val2 ); + Operands[StackPos] = (UINT8)(( Val1 == Val2 ) ? 1 : 0); + StackPos++; + break; + + case EFI_IFR_EQ_VAR_VAL_OP: + { + CHAR16 VarName[VARIABLE_NAME_LENGTH]; + UINTN size, *VarVal, Value; + EFI_GUID *VarGuid; + PAGE_INFO *pageInfo; + + VarValPtr = (VOID*)(CondPtr+i); + + //Get the variable name + SPrint(VarName, sizeof(VarName), L"%d",VarValPtr->VariableId); + + //Get the guid + pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[controlInfo->ControlPageID]); + VarGuid = &(gPageIdInfo[pageInfo->PageIdIndex].PageGuid); + + //Get the value + size = 0; + VarVal = (UINTN *)VarGetNvramName(VarName,VarGuid,NULL,&size); +// EIP51899 +>> + Value = 0; + if (VarVal != 0) + MemCopy(&Value, VarVal, size); + else + VarVal = 0; +// EIP51899 <<+ + // Value = VarVal ? *VarVal : 0; // EIP51899 - + + Operands[StackPos] = (UINT8)(( (UINT16)Value == VarValPtr->Value ) ? 1 : 0) ; + StackPos++; + + //Free variable memory + MemFreePointer((VOID **)&VarVal); + } + break; + + case EFI_IFR_VARSTORE_SELECT_OP: + VarId1 = VarId2= GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT*)((char*)CondPtr +i))->VarId); + break; + + case EFI_IFR_VARSTORE_SELECT_PAIR_OP: + VarId1 = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->VarId); + VarId2 = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->SecondaryVarId); + break; + + case EFI_IFR_END_IF_OP: + default: + Inside = FALSE; + break; + } + + // go to next opcode + i +=(UINT32)*(CondPtr+i+1); + } + + if(GetExpResult()) + FinalCond = UpdateFinalCondition(FinalCond,Cond); + + // if CtrlAccess is CONTROL_ACCESS_DEFAULT then do not override VFR conditions + if(CONTROL_ACCESS_DEFAULT != CtrlAccess) + { + FinalCond = CheckControlAccess(CtrlAccess); + } + + return FinalCond; +} +#else +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CheckControlCondition +// +// Description: This function eveluates the condition and retuns the result +// +// Input: Control Info +// +// Output: COND_NONE - Condition failed. +// COND_SUPPRESS - Condition matchs suppress +// COND_GRAYOUT - Condition matchs Grayout +// COND_HIDDEN - Condition matchs and Hide +// COND_INCONSISTENT - Inconsistent Condition matchs +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 CheckControlCondition( CONTROL_INFO *controlInfo ) +{ + // Used to be a long list of parameters + UINT32 CtrlAccess; + UINT8 *CtrlPtr; + UINT32 CtrlVar, CtrlVar2; + UINT8 *CondPtr; + + UINT8 Cond = COND_NONE, FinalCond = COND_NONE, tempresult = FALSE, result = FALSE, x; + UINT8 OpStack[5], StackPos = 0; + UINT32 i=0,Var = 0, Var2 = 0; + EFI_IFR_EQ_ID_VAL *IDValPtr; + EFI_IFR_EQ_ID_LIST *IDListPtr; + EFI_IFR_EQ_VAR_VAL *VarValPtr; + EFI_IFR_EQ_ID_ID *IDIDPtr; + + BOOLEAN Inside = TRUE; + + UINT32 tCtrlVar, tCtrlVar2; + + CtrlAccess = controlInfo->ControlFlags.ControlAccess; + CtrlPtr = (UINT8 *)controlInfo->ControlPtr; + tCtrlVar = + CtrlVar = controlInfo->ControlConditionalVariable[0]; + tCtrlVar2 = + CtrlVar2 = controlInfo->ControlConditionalVariable[1]; + CondPtr = (UINT8 *)controlInfo->ControlConditionalPtr; + + if ( CondPtr == NULL ) + return ( CheckControlAccess(CtrlAccess) ); + + + while( Inside ) + { + Var = 0 ; + + switch(*(CondPtr+i)) + { + // note: (size matters!!!!) this code is done before the while loop + case EFI_IFR_SUPPRESS_IF_OP: // supress_if + if(result) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + result = COND_NONE; + } + + Cond = COND_SUPPRESS; + break; + + case EFI_IFR_GRAYOUT_IF_OP: // grayout_if + if(result) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + result = COND_NONE; + } + Cond = COND_GRAYOUT; + break; + + case EFI_IFR_HIDDEN_OP: // hidden _if + if(result) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + result = COND_NONE; + } + Cond = COND_HIDDEN; + break; + + case EFI_IFR_NOT_OP: + /*StackPos++; + OpStack[StackPos] = EFI_IFR_NOT_OP ; + continue; + */ + //break; // on purpose to go on code below (size matters) + + case EFI_IFR_AND_OP: + /*StackPos++; + OpStack[StackPos] = EFI_IFR_AND_OP ; + tempresult = result; + continue; + */ + //break; // on purpose to go on code below (size matters) + + case EFI_IFR_OR_OP: + StackPos++; + OpStack[StackPos] = *(CondPtr+i) ;//EFI_IFR_OR_OP; + tempresult = result; + i +=(UINT32)*(CondPtr+i+1); + continue; + break; + + case EFI_IFR_EQ_ID_VAL_OP: + IDValPtr = (VOID*)(CondPtr+i); + VarGetValue( tCtrlVar, IDValPtr->QuestionId, IDValPtr->Width, &Var ); + result = ( (UINT16)Var == IDValPtr->Value ) ? 1 : 0 ; + break; + + case EFI_IFR_EQ_ID_LIST_OP: + IDListPtr = (VOID*)(CondPtr+i); + VarGetValue( tCtrlVar, IDListPtr->QuestionId, IDListPtr->Width, &Var ); + for ( Var2 = 0; Var2 < IDListPtr->ListLength; Var2++ ) + { + result = (UINT8)( IDListPtr->ValueList[Var2] == Var ); + if ( result ) + break; + } + break; + + case EFI_IFR_EQ_ID_ID_OP: + IDIDPtr = (VOID*)(CondPtr+i); + VarGetValue( tCtrlVar, IDIDPtr->QuestionId1, IDIDPtr->Width, &Var ); + VarGetValue( tCtrlVar2, IDIDPtr->QuestionId2, IDIDPtr->Width, &Var2 ); + result = (UINT8)(( Var == Var2 ) ? TRUE : FALSE); //WARN FIX + + //result = ; + break; + + case EFI_IFR_EQ_VAR_VAL_OP: + { + CHAR16 VarName[VARIABLE_NAME_LENGTH]; + UINTN size, *VarVal, Value; + EFI_GUID *VarGuid; + PAGE_INFO *pageInfo; + + VarValPtr = (VOID*)(CondPtr+i); + + //Get the variable name + SPrint(VarName, sizeof(VarName), L"%d",VarValPtr->VariableId); + + //Get the guid + pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[controlInfo->ControlPageID]); + VarGuid = &(gPageIdInfo[pageInfo->PageIdIndex].PageGuid); + + //Get the value + size = 0; + VarVal = (UINTN *)VarGetNvramName(VarName,VarGuid,NULL,&size); + Value = VarVal ? *VarVal : 0; + + result = (UINT8)(( (UINT16)Value == VarValPtr->Value ) ? TRUE : FALSE) ; //WARN FIX + + //Free variable memory + MemFreePointer((VOID **)&VarVal); + } + break; + + case EFI_IFR_VARSTORE_SELECT_OP: + tCtrlVar = tCtrlVar2= GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT*)((char*)CondPtr +i))->VarId); + // franklyn added next two lines for testing 1/10/2006 + i +=(UINT32)*(CondPtr+i+1); + continue; + break; + + case EFI_IFR_VARSTORE_SELECT_PAIR_OP: + tCtrlVar = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->VarId); + tCtrlVar2 = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->SecondaryVarId); + // franklyn added next two lines for testing 1/10/2006 + i +=(UINT32)*(CondPtr+i+1); + continue; + break; + + case EFI_IFR_INCONSISTENT_IF_OP: // grayout_if + if(result) + { + FinalCond = UpdateFinalCondition(FinalCond,Cond); + result = COND_NONE; + } + Cond = COND_INCONSISTENT; + break; + + case EFI_IFR_END_IF_OP: + default: + Inside = FALSE; + break; + } + + // go to next opcode + i +=(UINT32)*(CondPtr+i+1); + + if(StackPos !=0) + { + // process stack operation with result and, if necessary, tempresult + switch(OpStack[StackPos]) + { + case EFI_IFR_AND_OP: + result = tempresult & result; + break; + + case EFI_IFR_OR_OP: + result = tempresult | result; + break; + + case EFI_IFR_NOT_OP: + result = !result; + if(StackPos !=1) + { + x =result; + result = tempresult; + tempresult = x; + } + break; + + default : + // wrong opcode!!! abort parsing and return condition false + return COND_NONE; + break; + } + + StackPos--; + } + } + + if(result) + FinalCond = UpdateFinalCondition(FinalCond,Cond); + + // if CtrlAccess is CONTROL_ACCESS_DEFAULT then do not override VFR conditions + if(CONTROL_ACCESS_DEFAULT != CtrlAccess) + { + FinalCond = CheckControlAccess(CtrlAccess); + } + + return FinalCond; +} +#endif + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CheckInconsistence +// +// Description: check for inconsistancy +// +// Input: PAGE_INFO *pPageInfo +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN CheckInconsistence( PAGE_INFO *pPageInfo ) +{ + CONTROL_INFO *pControlInfo; + UINTN i; + + //Find out if there is inconsistent value in any of the controls + for(i=0; i < pPageInfo->PageControls.ControlCount; i++) + { + pControlInfo = (CONTROL_INFO*)((UINT8 *)(gControlInfo) + pPageInfo->PageControls.ControlList[i]); + //Check if there is a CONTROL_TYPE_MSGBOX in this page + if(pControlInfo->ControlType == CONTROL_TYPE_MSGBOX) + { + if(CheckControlCondition(pControlInfo) == COND_INCONSISTENT) + { + //Draw message box + EFI_STATUS Status; + MSGBOX_DATA *msgbox = NULL; + CONTROL_INFO dummy; + AMI_IFR_MSGBOX MsgData; + ACTION_DATA *action = gApp->Action; + + Status = gMsgBox.Create( &msgbox ); + if ( EFI_ERROR( Status ) ) + return TRUE; // Not able to draw msg box but thats ok dont allow a page switch + + MemSet( &dummy, sizeof(dummy), 0 ); + dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE; + + MsgData.Opcode = 0; + MsgData.Length = 0; + MsgData.Title = STRING_TOKEN(STR_INCONSISTENT_MSG_TITLE); + MsgData.TextHandle = pControlInfo->ControlHandle; + MsgData.Text = ((EFI_IFR_INCONSISTENT*)pControlInfo->ControlConditionalPtr)->Popup ; //pControlInfo->ControlHelp; + + dummy.ControlPtr = (VOID*) (&MsgData); + dummy.ControlFlags.ControlVisible = TRUE; + + Status = gMsgBox.Initialize( msgbox, &dummy ); + if ( EFI_ERROR( Status ) ) + { + gMsgBox.Destroy( msgbox, TRUE );; + return TRUE; // Not able to draw msg box but thats ok dont allow a page switch + } + + gMsgBox.SetType( msgbox, MSGBOX_TYPE_OK | MSGBOX_STYLE_LEFT ); + + do + { + if ( action->Input.Type != ACTION_TYPE_NULL ) + gAction.ClearAction( action ); + + gMsgBox.Draw( msgbox ); + + if ( gAction.GetAction( action ) != EFI_SUCCESS ) + continue; + + if(gMsgBox.HandleAction( msgbox, action ) == EFI_SUCCESS) + break; + DoRealFlushLines(); + }while(1); + + gMsgBox.Destroy( msgbox, TRUE ); + + return TRUE; + } + } + } + return FALSE; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CheckNoSubmitIf +// +// Description: checks NoSubmitIf +// +// Parameter: VOID +// +// Return value: BOOLEAN +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN CheckNoSubmitIf( VOID) +{ + //NO_SUBMIT_IF is Unsupport in 2.0 + return FALSE; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/uefi2.0/ctrlcond.h b/EDK/MiniSetup/uefi2.0/ctrlcond.h new file mode 100644 index 0000000..f2ae342 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/ctrlcond.h @@ -0,0 +1,113 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.h $ +// +// $Author: Arunsb $ +// +// $Revision: 7 $ +// +// $Date: 10/18/12 6:00a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.h $ +// +// 7 10/18/12 6:00a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:39p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 6 3/29/11 1:15p Madhans +// [TAG] EIP56414 +// [Category] Improvement +// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode +// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c, +// CtrlCond.h, ctrlcond.h, ctrlcond.c +// +// 5 3/29/11 1:13p Madhans +// [TAG] EIP56414 +// [Category] Improvement +// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode +// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c, +// CtrlCond.h, ctrlcond.h, ctrlcond.c +// +// 4 2/19/10 1:04p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 5 2/19/10 8:20a Mallikarjunanv +// updated year in copyright message +// +// 4 1/09/10 7:25a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:08p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: ctrlcond.h +// +// Description: Header file for control conditions +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "minisetup.h" + +//definitions +#define COND_NONE 0x0 +#define COND_SUPPRESS 0x1 +#define COND_HIDDEN 0x2 +#define COND_GRAYOUT 0x3 +#define COND_INCONSISTENT 0x4 + +// functions +UINT8 CheckControlCondition( CONTROL_INFO *controlInfo ); +BOOLEAN CheckInconsistence( PAGE_INFO *pPageInfo ); +BOOLEAN CheckNoSubmitIf( VOID); // EIP : NO_SUBMIT_IF + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/uefi2.0/hii.c b/EDK/MiniSetup/uefi2.0/hii.c new file mode 100644 index 0000000..0e6b2c8 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/hii.c @@ -0,0 +1,3273 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.c $ +// +// $Author: Arunsb $ +// +// $Revision: 23 $ +// +// $Date: 4/18/13 9:35a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.c $ +// +// 23 4/18/13 9:35a Arunsb +// Dummy functions added to avoid build error in 2.0 build +// +// 22 3/25/13 8:32a Premkumara +// [TAG] EIP116315 +// [Category] Improvement +// [Description] Display control prompt string for password control. +// (for String on CHAP secret popup) +// [Files] - AMITSE.sdl +// - CommonHelper.c +// - FakeToken.c +// - AmiTSEStr.uni +// - TseLite\PopupPassword.c +// - uefi2.1\UefiWapper21.c +// - uefi2.0\HiiCallback.c +// - uefi2.0\hii.h +// - uefi2.0\hii.c +// +// 21 10/18/12 6:00a Arunsb +// Updated for 2.16.1235 QA submission +// +// 17 10/10/12 12:39p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 19 9/25/12 3:04p Arunsb +// RTIfrRegFormNotificationWrapper function call removed +// +// 17 6/04/11 12:26p Arunsb +// [TAG] EIP48930 +// [Description] Boot override hangs with exception 0x0d +// [Files] uefi2.1\Parse.c, uefi2.0\hii.c +// +// 16 6/01/11 5:22p Blaines +// [TAG] 61122 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] If SETUP_ORPHAN_PAGES_AS_ROOT_PAGE=1, HiiExit() will cause +// an ASSERT in pool.c if debug_mode is enabled. +// [RootCause] HiiExit() exit attempts to free gSetupData elements +// associated with orphaned forms.. +// [Solution] Only free gSetupData[i].FormSet if +// gSetupData[i].FormSetLength is non-zero. +// [Files] Hii.c +// +// 15 5/31/11 9:51a Premkumara +// [TAG] EIP48930 +// [Description] Boot override hangs with exception 0x0d +// [Files] hii.c, Parse.c +// +// 14 3/28/11 10:05p Premkumara +// [TAG] 52562 +// [Category] Enhancement +// [Description] Need to have the Fixed Limit in AMITSE module for +// Controls, Pages and Variable etc. +// [Files] TSEUefiHii.h, Parse.c, Hii.c, hii.c +// +// 13 2/10/11 12:32p Blaines +// [TAG] - EIP 53146 +// [Category]- New Feature +// [Description] -Add the support to Move the Dynamic IFR Pages under +// subpages. It should be customizable to move around. +// +// 12 2/03/11 3:47p Mallikarjunanv +// Initialized the control flags properly +// +// 11 2/03/11 1:04p Mallikarjunanv +// Fixed the issue in TSE Lite with respect to setting control info read +// only flags. Which caused issues when selecting some controls. +// +// 10 2/03/11 12:40p Mallikarjunanv +// [TAG] EIP48587 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Press "F3" not loading the optimized defaults for controls +// [RootCause] Defaults were not updated properly for UEFI 2.0 +// [Solution] Updated the defaults values based on controls offsets and +// check box controls are modified as one-of options. +// [Files] hii.c +// +// 9 10/05/10 3:50p Madhans +// [TAG] - EIP 45511 +// [Category]- BUG FIX +// [Severity]- Major +// [Symptom]- TSE 2.10 with UEFI 2.0 may not work with Runtime Prasing. It +// crashs the system. +// [RootCause]- Initilization of VARIABLE_INFO is affected becaus of UEFI +// 2.1 modifications. +// [Solution]- Initlize the VARIABLE_INFO Strcture with Zero. +// [Files] - hii.c +// +// 8 7/23/10 5:21p Blaines +// Fix root page processing to support Award Style setup. +// +// 7 2/26/10 8:54p Madhans +// For TSE 2.01.1024. refer changelog.log for file checkin history . +// +// 11 2/25/10 7:08p Madhans +// To build the defaults with the NVRAM values. This will avoid issues +// caused when defaults load. +// +// 10 2/19/10 8:20a Mallikarjunanv +// updated year in copyright message +// +// 9 2/17/10 11:26p Madhans +// default Var Attribute for the Var store updated to BS+RT+NV +// +// 8 1/09/10 7:25a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 7 12/22/09 6:40p Madhans +// // EIP: 32318 fix for the crash issue when the page has many controls. +// +// 6 8/20/09 3:11p Madhans +// //EIP 25092 : Fix to Use the HiiChangeString() to Add the string for +// morethen one langs. +// +// 5 8/13/09 7:42a Mallikarjunanv +// modified and moved the function HiiGetEfiKey from binary to uefi module +// +// 4 7/23/09 8:52a Mallikarjunanv +// updated function InitFormsetLinks for eip-24060 +// +// 3 6/23/09 6:51p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:08p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:14p Madhans +// UEFI Wrapper improvments. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: hii.c +// +// Description: This file contains code to handle the uefi2.0 based hii operations +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "minisetup.h" +#include EFI_PROTOCOL_DEFINITION(Hii) +#include EFI_PROTOCOL_DEFINITION(FormCallback) +extern EFI_HII_PROTOCOL *gHiiProtocol; + +// Maximum supported page, variables, controls. +#define MAX_PAGE 100 +#define MAX_CONTROLS 0xFFFF +#define MAX_VARIABLE 100 +//--------------------------------------------------------------------------- +static VOID* *gSetupHandles = NULL; +UINTN gSetupCount = 0; +#pragma pack(1) +typedef struct +{ + UINT8 *FormSet; + VOID *Handle; + UINT16 ClassID; + UINTN FormSetLength; + UINT8 Added; //To know if this page was present in the tool data + UINT16 SubClassID; +} +SETUP_LINK; +#pragma pack() + +UINTN gDynamicPageCount=0; +static SETUP_LINK *gSetupData = NULL; + +static UINT32 ControlListSize, ControlListOffset; + +static PAGE_LIST *PageListPtr; +static PAGE_INFO *PageInfoPtr; +static UINT32 PageListSize, PageListOffset, PageInfoSize, PageInfoOffset; + +static UINT32 AllocatedFirstPageSize = 0, FirstPageOffset = 0; +static PAGE_INFO *FirstPage = NULL; + +EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle ); +EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index ); + +UINT32 AddControlToList(CONTROL_INFO *NewControlInfo, UINT32 ControlSize); +VOID AddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize); +VOID CreatePage(PAGE_INFO **PageInfo, UINT32 *AllocatedSize, UINT32 *Offset, VOID *Buff, UINT32 BuffSize); +VOID MergePageListAndInfo(); + + +VOID RTIfrProcessExitWrapper(VOID); +VOID RTIfrProcessAddVarListAndPageIDListWrapper(VOID); +BOOLEAN RTIfrProcessFormIfUpdatedWrapper(UINT16 link); +VOID RTIfrProcessRunTimeFormsWrapper(EFI_IFR_REF **ref); + +VOID AddDynamicForm(UINT32 HiiIndex); +int AddVariable(EFI_IFR_VARSTORE *Varstore); +VOID AddPageIdToList(PAGE_ID_INFO *NewPageIdInfo, UINT32 PageIdSize); +VOID MergePageIdListAndInfo(); +VOID AddVariableToList(VARIABLE_INFO *NewVariableInfo, UINT32 VariableSize); +VOID MergeVariableListAndInfo(); +UINTN AddHpkControls(UINT32 HiiIndex, UINT8 *buff,UINTN size, PAGE_INFO **NewPageInfo, UINT32 *AllocatedPageSize, UINT32 *PageOffset); +EFI_STATUS _DisplayErrorMessage(CHAR16 *Temp); + +static PAGE_ID_LIST *PageIdListPtr; +static PAGE_ID_INFO *PageIdInfoPtr; +static UINT32 PageIdListSize, PageIdListOffset, PageIdInfoSize, PageIdInfoOffset; + +static VARIABLE_LIST *VariableListPtr; +static VARIABLE_INFO *VariableInfoPtr; +static UINT32 VariableListSize, VariableListOffset, VariableInfoSize, VariableInfoOffset; + +#define DEFAULT_REFRESH_RATE 0x01 +#define DEFAULT_DATETIME_REFRESH 0x05 +#define FORM_SUBCLASS 3 +#define CONTROL_TYPE_TITLE CONTROL_TYPE_NULL +#define CONTROL_TYPE_MASK 0x0FFF + +#define START_EVAL_IF 0x8000 +#define END_EVAL_IF 0x8001 + +typedef struct PAGELINK +{ + UINT16 FormID; // number from hpk + UINT16 ParentPageID; // number from the tool + UINT16 PageNum; // number assigned by the tool + +}PageLink; + +typedef struct _VAR_KEY_TABLE +{ + UINT32 VarId; + UINT16 Index; + struct _VAR_KEY_TABLE *Next; +}*PVAR_KEY_TABLE, VAR_KEY_TABLE; + +VAR_KEY_TABLE VarKeyTable; + +typedef struct FORMSETLINKS +{ + UINT16 PageCount; + PageLink PageLink[20]; +}FormSetLinks; + +FormSetLinks *FSetLinks = NULL; + +UINT32 CtrlVar=0, CtrlCondVar=0, CtrlCondVar2=0, ActualCondVar=0, ActualCondVar2=0; +UINT32 controllabel=0,controlindex=0; +UINTN updatecondvars=1; + +unsigned short controltypes[] = +{ + CONTROL_TYPE_TITLE, //#define EFI_IFR_FORM_OP 0x01 + CONTROL_TYPE_MEMO, //#define EFI_IFR_SUBTITLE_OP 0x02 + CONTROL_TYPE_TEXT, //#define EFI_IFR_TEXT_OP 0x03 + 0x0, //#define EFI_IFR_GRAPHIC_OP 0x04 + CONTROL_TYPE_POPUPSEL, //#define EFI_IFR_ONE_OF_OP 0x05 + CONTROL_TYPE_CHECKBOX, //#define EFI_IFR_CHECKBOX_OP 0x06 + CONTROL_TYPE_NUMERIC, //#define EFI_IFR_NUMERIC_OP 0x07 + CONTROL_TYPE_PASSWORD, //#define EFI_IFR_PASSWORD_OP 0x08 + 0x0, //#define EFI_IFR_ONE_OF_OPTION_OP 0x09 // ONEOF OPTION field + START_EVAL_IF, //#define EFI_IFR_SUPPRESS_IF_OP 0x0A + 0x0, //#define EFI_IFR_END_FORM_OP 0x0B + 0x0, //#define EFI_IFR_HIDDEN_OP 0x0C + 0x0, //#define EFI_IFR_END_FORM_SET_OP 0x0D + 0x0, //#define EFI_IFR_FORM_SET_OP 0x0E + CONTROL_TYPE_SUBMENU, //#define EFI_IFR_REF_OP 0x0F + 0x0, //#define EFI_IFR_END_ONE_OF_OP 0x10 + //0x0, //#define EFI_IFR_END_OP EFI_IFR_END_ONE_OF_OP + INCONSISTENT_IF, //#define EFI_IFR_INCONSISTENT_IF_OP 0x11 + 0x0, //#define EFI_IFR_EQ_ID_VAL_OP 0x12 + 0x0, //#define EFI_IFR_EQ_ID_ID_OP 0x13 + 0x0, //#define EFI_IFR_EQ_ID_LIST_OP 0x14 + 0x0, //#define EFI_IFR_AND_OP 0x15 + 0x0, //#define EFI_IFR_OR_OP 0x16 + 0x0, //#define EFI_IFR_NOT_OP 0x17 + END_EVAL_IF, //#define EFI_IFR_END_IF_OP 0x18 // for endif of inconsistentif, suppressif, grayoutif + START_EVAL_IF, //#define EFI_IFR_GRAYOUT_IF_OP 0x19 + CONTROL_TYPE_DATE, //#define EFI_IFR_DATE_OP 0x1A + CONTROL_TYPE_TIME, //#define EFI_IFR_TIME_OP 0x1B + CONTROL_TYPE_POPUP_STRING, //#define EFI_IFR_STRING_OP 0x1C + 0x0, //#define EFI_IFR_LABEL_OP 0x1D // defines location where controls can be added + 0x0, //#define EFI_IFR_SAVE_DEFAULTS_OP 0x1E + 0x0, //#define EFI_IFR_RESTORE_DEFAULTS_OP 0x1F + 0x0, //#define EFI_IFR_BANNER_OP 0x20 + 0x0, //#define EFI_IFR_INVENTORY_OP 0x21 + 0x0, //#define EFI_IFR_EQ_VAR_VAL_OP 0x22 + CONTROL_TYPE_ORDERED_LIST, //#define EFI_IFR_ORDERED_LIST_OP 0x23 + CONTROL_TYPE_VARSTORE, //#define EFI_IFR_VARSTORE_OP 0x24 + CONTROL_TYPE_VARSTORE_SELECT, //#define EFI_IFR_VARSTORE_SELECT_OP 0x25 + CONTROL_TYPE_VARSTORE_SELECT_PAIR, //#define EFI_IFR_VARSTORE_SELECT_PAIR_OP 0x26 + 0x0, //#define EFI_IFR_LAST_OPCODE EFI_IFR_VARSTORE_SELECT_PAIR_OP + 0x0, //#define EFI_IFR_NV_ACCESS_COMMAND 0xFF +}; + + + +UINTN TotalRootPages; + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiExit +// +// Description: performs the operations that required to exit from HII +// +// Input: VOID +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS HiiExit( VOID ) +{ + UINTN i; + + //Remove gSetupHandles + MemFreePointer((VOID**)&gSetupHandles); + + // Remove memory held by gSetupData + for ( i = 0; i < gSetupCount; i++ ) + { + //EIP:61122, Free memory only if gSetupData[i].FormSetLength is non-zero. + if(gSetupData[i].FormSetLength) + MemFreePointer(&(gSetupData[i].FormSet)); + } + MemFreePointer(&gSetupData); + gSetupCount = 0; + + MemFreePointer(&gControlInfo); + ControlListSize = ControlListOffset = 0; + + MemFreePointer(&gApplicationData); + + gPages = gToolPages; + PageListPtr = NULL; + PageInfoPtr = NULL; + FirstPage = NULL; + AllocatedFirstPageSize = FirstPageOffset = PageListSize = PageListOffset = PageInfoSize = PageInfoOffset = 0; + + RTIfrProcessExitWrapper(); + + gVariables = gToolVariables; + gPageIdList = gToolPageIdList; + gPageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[0]); + + return EFI_SUCCESS; +} + +VOID FixupPage0ControlInfo( UINTN FormSet, UINTN ControlPtr, VOID* Handle) +{ + PAGE_INFO *pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[0]); + CONTROL_INFO *controlInfo = NULL; + UINT32 j; + + if(pageInfo->PageControls.ControlCount) + { + for ( j = 0; j < pageInfo->PageControls.ControlCount; j++ ) + { + controlInfo = (CONTROL_INFO*)((UINTN)gToolControlInfo + pageInfo->PageControls.ControlList[j]); + if( (ControlPtr-FormSet) == (UINTN)controlInfo->ControlPtr ) + { + controlInfo->ControlHandle = Handle; + controlInfo->ControlPtr = (VOID*)ControlPtr; + } + } + } + +} + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiFixupData +// +// Description: Function to fixup hhi data +// +// Input: NIL +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS HiiFixupData( ) +{ + EFI_STATUS Status = EFI_SUCCESS; + UINT32 i, j=0; + + PAGE_INFO *pageInfo = NULL; + EFI_IFR_FORM_SET *formSet; + EFI_IFR_REF *ref = NULL; + + UINT16 link; + + Status = _HiiLocateSetupHandles(); + if ( EFI_ERROR( Status ) ) + return Status; + + gSetupData = EfiLibAllocateZeroPool( sizeof(SETUP_LINK) * gSetupCount ); + if ( gSetupData == NULL ) + return EFI_OUT_OF_RESOURCES; + + for ( i = 0; i < gSetupCount - 1; i++ ) + { + gSetupData[i].FormSet = _HiiGetForm( gSetupHandles[i], 0, &(gSetupData[i].FormSetLength) ); + if ( gSetupData[i].FormSet == NULL ) + { + // make sure the handle is also zero + gSetupData[i].Handle = 0 ; + continue; + } + gSetupData[i].Handle = gSetupHandles[i]; + formSet = HiiGetFormSet( i ); + gSetupData[i].ClassID = formSet->Class; + gSetupData[i].SubClassID = formSet->SubClass; + + } + + // need to allocate one more dynamic IFR for the root page, this is NOT a 100% valid + // formset as there is no form defined + gSetupData[i].FormSet = EfiLibAllocateZeroPool( + sizeof(EFI_HII_PACK_HEADER) + + sizeof(EFI_IFR_FORM_SET) + + i * sizeof(EFI_IFR_REF) + ); + + formSet = HiiGetFormSet(i); + MemCopy(&(formSet->Guid),&(gSetupPkg->PackageGuid),sizeof(EFI_GUID)); + + TotalRootPages = 0; + + if ( gSetupData[i].FormSet != NULL ) + { + ref = (EFI_IFR_REF *)(gSetupData[i].FormSet + sizeof(EFI_HII_PACK_HEADER) + sizeof(EFI_IFR_FORM_SET)); + for ( j = 1; j <= gToolPages->PageCount; j++ ) + { + pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[j]); + if ( pageInfo->PageParentID != 0 ) //if ( pageInfo->PageFormID != 1 ) + continue; + + TotalRootPages++; + + link = _HiiGetLinkIndex( &(gToolPageIdInfo[pageInfo->PageIdIndex].PageGuid), + gToolPageIdInfo[pageInfo->PageIdIndex].PageClass, + gToolPageIdInfo[pageInfo->PageIdIndex].PageSubClass, + pageInfo->PageFormID); + + if ( link == (gSetupCount - 1) ) + continue; + + formSet = HiiGetFormSet( link ); + ref->Header.OpCode = EFI_IFR_REF_OP; + ref->Header.Length = sizeof(EFI_IFR_REF); + ref->Prompt = formSet->FormSetTitle; + ref->Help = formSet->Help; + FixupPage0ControlInfo( (UINTN)gSetupData[i].FormSet, (UINTN)ref, (VOID*)gSetupData[link].Handle); + ref++; + } + + gSetupData[i].Handle = gSetupData[0].Handle; + + } + + RTIfrProcessAddVarListAndPageIDListWrapper(); + + // update the control (IFR) pointers and HII handles + for ( i = 0; i< gToolPages->PageCount; i++ ) + { + PAGE_INFO *NewPageInfo; + UINT32 PageSize; + UINT32 ControlSize; + CONTROL_INFO *NewControlInfo; + UINTN NoOfControlSpace; + + pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[i]); + + if(i == 0) + { + link = (UINT16)(gSetupCount - 1); + } + else + { + + link = _HiiGetLinkIndex( &(gToolPageIdInfo[pageInfo->PageIdIndex].PageGuid), + gToolPageIdInfo[pageInfo->PageIdIndex].PageClass, + gToolPageIdInfo[pageInfo->PageIdIndex].PageSubClass, + pageInfo->PageFormID); + } + + NoOfControlSpace = pageInfo->PageControls.ControlCount ? pageInfo->PageControls.ControlCount - 1 : pageInfo->PageControls.ControlCount; + PageSize = (UINT32)(sizeof(PAGE_INFO) + sizeof(pageInfo->PageControls.ControlList) * NoOfControlSpace); + NewPageInfo = EfiLibAllocateZeroPool(PageSize); + + MemCopy(NewPageInfo,pageInfo,PageSize); + + if ( link == (gSetupCount - 1) ) + { + NewPageInfo->PageHandle = 0;// This page has been removed in runtime!!! + } + else + { + if(RTIfrProcessFormIfUpdatedWrapper(link) == TRUE) + continue; + NewPageInfo->PageHandle = gSetupData[link].Handle; + } + + //Fixup and add the controls in this page to gContolInfo and update offsets in page info + if(NewPageInfo->PageControls.ControlCount) + { + for ( j = 0; j < NewPageInfo->PageControls.ControlCount; j++ ) + { + CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gToolControlInfo + NewPageInfo->PageControls.ControlList[j]); + + ControlSize = sizeof(CONTROL_INFO) + controlInfo->ControlDataWidth * 2; + + NewControlInfo = EfiLibAllocateZeroPool(ControlSize); + MemCopy(NewControlInfo, controlInfo, ControlSize); + + if(NewPageInfo->PageHandle != 0) + { + + NewControlInfo->ControlHandle = gSetupData[link].Handle; + + if ( NewControlInfo->ControlPtr != 0 ) + { + NewControlInfo->ControlPtr = (VOID*)((UINTN)NewControlInfo->ControlPtr + (UINTN)gSetupData[link].FormSet); + if ( NewControlInfo->ControlConditionalPtr != 0 ) + { + NewControlInfo->ControlConditionalPtr = (VOID*)((UINTN)NewControlInfo->ControlConditionalPtr + (UINTN)NewControlInfo->ControlPtr); + } + } + else if ( NewControlInfo ->ControlConditionalPtr != 0 ) + { + NewControlInfo ->ControlConditionalPtr = (VOID*)((UINTN)NewControlInfo ->ControlConditionalPtr+(UINTN)gSetupData[link].FormSet); + } + } + + NewPageInfo->PageControls.ControlList[j] = AddControlToList(NewControlInfo,ControlSize); //Update new offset in gControlInfo + + MemFreePointer(&NewControlInfo); + } + } + else + { + // Add the Empty Control to control List even if NewPageInfo->PageControls.ControlCount = 0 + CONTROL_INFO *controlInfo = (CONTROL_INFO*)((UINTN)gToolControlInfo + 0); + ControlSize = sizeof(CONTROL_INFO) + controlInfo->ControlDataWidth * 2; + NewControlInfo = EfiLibAllocateZeroPool(ControlSize); + MemCopy(NewControlInfo, controlInfo, ControlSize); + AddControlToList(NewControlInfo,ControlSize); //Update new offset in gControlInfo + MemFreePointer(&NewControlInfo); + } + + if(i==0) + { + CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, NewPageInfo, PageSize); + } + else + { + AddPageToList(NewPageInfo,PageSize); + } + MemFreePointer(&NewPageInfo); + } + + RTIfrProcessRunTimeFormsWrapper(&ref); + + MergePageListAndInfo(); + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiGetStringLength +// +// Description: Function to get the string length +// +// Input: VOID* handle, +// UINT16 token +// +// Output: Length +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINTN HiiGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token ) +{ + CHAR16 *string; + UINTN length = 0; + + string = HiiGetString( handle, token ); + if ( string == NULL ) + return length; + + length = EfiStrLen( string ); + MemFreePointer( (VOID **)&string ); + + return length; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiFindHandle +// +// Description: Function to find the perticular HII handle +// +// Input: EFI_GUID *guid, UINT16 *index +// +// Output: Handle +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +/*EFI_HII_HANDLE*/VOID* HiiFindHandle( EFI_GUID *guid, UINT16 *index ) +{ + VOID* *handleBuffer = NULL; + VOID* handle = (VOID*)(UINTN)INVALID_HANDLE; + + EFI_IFR_FORM_SET *formSet; + UINT8 *buffer; + + UINT16 found = 0; + UINT16 i, count; + + handleBuffer = _HiiGetHandles( &count ); + if ( handleBuffer == NULL ) + return handle; + + for ( i = found = 0; i < count; i++ ) + { + buffer = _HiiGetForm( handleBuffer[i], 0, NULL ); + if ( buffer == NULL ) + continue; + formSet = (EFI_IFR_FORM_SET *)(buffer + sizeof(EFI_HII_PACK_HEADER)); + if ( EfiCompareGuid( guid, &formSet->Guid ) ) + { + if ( *index == found ) + { + handle = handleBuffer[i]; + (*index)++; + break; + } + found++; + } + + MemFreePointer( &buffer ); + } + + MemFreePointer( (VOID **)&handleBuffer ); + return handle; + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: _HiiGetHandles +// +// Description: Function to get HII handles +// +// Input: UINT16 *bufferSize +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID* * _HiiGetHandles( UINT16 *bufferSize ) +{ + EFI_STATUS Status; + EFI_HII_HANDLE *buffer = NULL; + UINTN *OutBuf=NULL; + UINT16 i; + + *bufferSize = 0; + Status = _HiiWrapperFindHandles( bufferSize, NULL ); + if ( Status != EFI_BUFFER_TOO_SMALL ) + return (VOID*)OutBuf; + + buffer = EfiLibAllocatePool( *bufferSize ); + if ( buffer != NULL ) + { + Status = _HiiWrapperFindHandles( bufferSize, (VOID**)buffer ); + if ( EFI_ERROR( Status ) ) + MemFreePointer( (VOID **)&buffer ); + } + + *bufferSize /= sizeof(EFI_HII_HANDLE); + OutBuf = EfiLibAllocatePool( *bufferSize * sizeof(VOID*)); + + for(i=0;i<*bufferSize;i++) + OutBuf[i] = (UINTN)buffer[i]; + + MemFreePointer( (VOID **)&buffer ); + + //return buffer; + return (VOID*)OutBuf; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: _HiiLocateSetupHandles +// +// Description: Function to find the Setup Handles +// +// Input: void +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS _HiiLocateSetupHandles( VOID ) +{ + EFI_STATUS Status; + UINT16 i = 0; + UINT16 count; + /*EFI_HII_HANDLE*/VOID* *handleBuffer; + UINT8 *buffer; + UINT16 found = 0; + + Status = HiiInitializeProtocol(); + if ( EFI_ERROR( Status ) ) + return Status; + + if(FormBrowserLocateSetupHandles(&handleBuffer,&count)!= EFI_SUCCESS) + { + handleBuffer = _HiiGetHandles( &count ); + } + + if ( handleBuffer == NULL ) + { + Status = EFI_OUT_OF_RESOURCES; + goto _Done; + } + + gSetupHandles = EfiLibAllocatePool( (count + 1) * sizeof(/*EFI_HII_HANDLE*/VOID*) ); + if ( gSetupHandles == NULL ) + { + Status = EFI_OUT_OF_RESOURCES; + goto _Done; + } + + for ( i = found = 0; i < count; i++ ) + { + buffer = _HiiGetForm( handleBuffer[i], 0, NULL ); + if ( buffer == NULL ) + continue; + + gSetupHandles[found] = handleBuffer[i]; + found++; + MemFreePointer( &buffer ); + } + + gSetupCount = found + 1; + // EIP : maximum VFRs supported in TSE + if(gSetupCount > MAX_PAGE) + { + CHAR16 *Temp = L"Reached TSE Maximum supported Page"; + _DisplayErrorMessage(Temp); + ASSERT(0); + } + + // at this point we have all the setup specific HII handles into our buffer +_Done: + if(!FormBrowserHandleValid()) + MemFreePointer( (VOID**)&handleBuffer ); + + return Status; + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiGetFormSetFromHandle +// +// Description: Function to get formset handle +// +// Input: VOID* handle +// +// Output: Formset +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle ) +{ + UINTN i; + + for ( i = 0; i < gSetupCount; i++ ) + { + if ( gSetupHandles[i] == handle ) + return HiiGetFormSet( i ); + } + + return NULL; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiGetFormSet +// +// Description: Function to get formset +// +// Input: UINTN index +// +// Output: formset +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index ) +{ + EFI_IFR_FORM_SET *formSet = NULL; + + if ( index >= gSetupCount ) + return formSet; + + if ( gSetupData == NULL ) + return formSet; + + formSet = (EFI_IFR_FORM_SET*)(gSetupData[index].FormSet + sizeof(EFI_HII_PACK_HEADER)); + + return formSet; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: _HiiGetForm +// +// Description: to get data using the input handle +// +// Input: VOID* handle, UINT16 form, UINTN *Length +// +// Output: info buffer +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID *_HiiGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *Length ) +{ + EFI_STATUS Status; + VOID *buffer = NULL; + +#if HII_VERSION <= 1 + UINT16 bufferSize = 0; +#else + UINTN bufferSize = 0; +#endif + + Status = HiiInitializeProtocol(); + + if ( EFI_ERROR(Status) ) + return buffer; + + Status = _HiiWrapperGetForm( handle, form, &bufferSize, buffer ); + if ( Status != EFI_BUFFER_TOO_SMALL ) + return buffer; + + buffer = EfiLibAllocatePool( bufferSize ); + if ( buffer == NULL ) + return buffer; + + Status = _HiiWrapperGetForm( handle, form, &bufferSize, buffer ); + if ( EFI_ERROR(Status) ) + MemFreePointer( (VOID **)&buffer ); + + if(Length!=NULL) + *Length = bufferSize; + + return buffer; +} + + +UINT16 HiiAddStringLanguage( VOID* handle, CHAR16 *lang, CHAR16 *string ) +{ + return HiiChangeStringLanguage( handle, 0, lang, string ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiChangeString +// +// Description: to change a existing string +// +// Input: VOID* handle, UINT16 token, CHAR16 *string +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 HiiChangeString( VOID* handle, UINT16 token, CHAR16 *string ) +{ + UINTN i; + UINT16 returntoken; + UINT16 status = token; + + for ( i = 0; i < gLangCount; i++ ) + { + returntoken = HiiChangeStringLanguage( handle, token, gLanguages[i].Unicode, string ); + if ( token != returntoken ) + { + //EIP 25092 : Fix to Use the HiiChangeString() to Add the string for morethen one langs. + //with the same token. + token = status = returntoken; + } + } + return status; +} + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: IsFormFound +// +// Description: to check whether the perticular form found or not +// +// Input: EFI_IFR_FORM_SET *formSet,UINT16 formid +// +// Output: 0/1 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 IsFormFound(EFI_IFR_FORM_SET *formSet,UINT16 formid ) +{ + UINT8 * RawData = (UINT8 *)formSet; + while( ((EFI_IFR_OP_HEADER*)RawData)->OpCode != EFI_IFR_END_FORM_SET_OP) + { + if(((EFI_IFR_OP_HEADER*)RawData)->OpCode == EFI_IFR_FORM_OP) + if(((EFI_IFR_FORM*)RawData)->FormId == formid) + return 1; + + RawData += ((EFI_IFR_OP_HEADER*)RawData)->Length; + } + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: _HiiGetLinkIndex +// +// Description: to get the index of the link +// +// Input: EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid +// +// Output: Index +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 _HiiGetLinkIndex( EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid ) +{ + UINT16 i; + EFI_IFR_FORM_SET *formSet; + EFI_HII_PACK_HEADER *pack; + + for ( i = 0; i < gSetupCount - 1; i++ ) + { + pack = (EFI_HII_PACK_HEADER *)gSetupData[i].FormSet; + + if ( sizeof(EFI_HII_PACK_HEADER) == pack->Length ) + continue; + + formSet = (EFI_IFR_FORM_SET *)((UINT8 *)pack + sizeof(EFI_HII_PACK_HEADER)); + + if(EfiCompareGuid( guid , &(formSet->Guid) )) + { + if( gSetupData[i].ClassID == class ) + { + if( gSetupData[i].SubClassID == subclass ) + { + if(IsFormFound(formSet, formid)) + { + break; + } + } + } + } + } + return i; +} + +EFI_STATUS _HiiWrapperFindHandles( UINT16 *bufferSize, /*EFI_HII_HANDLE*/VOID* *buffer ) +{ + return gHiiProtocol->FindHandles( gHiiProtocol, bufferSize, (EFI_HII_HANDLE*)buffer ); +} + +#if HII_VERSION <= 1 +EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINT16 *bufferSize, VOID *buffer ) +#else +EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *bufferSize, VOID *buffer ) +#endif +{ + return gHiiProtocol->GetForms( gHiiProtocol,(EFI_HII_HANDLE)(UINTN) handle, form, bufferSize, buffer ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: _HiiParseVariablePack +// +// Description: To parse the variable pack and Update the Current Values with Default Values +// +// Input: EFI_HII_VARIABLE_PACK_LIST *packList, NVRAM_VARIABLE **pVarList +// +// Output: void +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID _HiiParseVariablePack( EFI_HII_VARIABLE_PACK_LIST *packList, UINT32 offs, UINT32 variable, UINTN size, NVRAM_VARIABLE **pVarList ) +{ + EFI_HII_VARIABLE_PACK *pack; + UINT32 index; + UINTN offset; + NVRAM_VARIABLE *varList = *pVarList; + NVRAM_VARIABLE *varPtr; + UINT8 *srcBuffer; + + for ( ; packList != NULL; packList = packList->NextVariablePack ) + { + pack = packList->VariablePack; + if ( pack == NULL ) + continue; + + if ( VarGetVariableInfoId( pack->VariableId, &index ) == NULL ) + continue; + + offset = sizeof(EFI_HII_VARIABLE_PACK) + pack->VariableNameLength; +//--> EIP:48587 + if( index == variable) + { + varPtr = &(varList[index]); + if ( offs + size > varPtr->Size ) + { + UINT8 *pnewBuffer; + pnewBuffer = EfiLibAllocateZeroPool( offs + size ); + MemCopy( pnewBuffer, varPtr->Buffer, varPtr->Size ); + MemFreePointer( (VOID **)&varPtr->Buffer ); + varPtr->Buffer = pnewBuffer; + varPtr->Size = offs + size; + } + srcBuffer = (UINT8 *)pack + offset; + if( variable == pack->VariableId ) + { + // Update the Current Values with Defaults values + MemCopy( &varPtr->Buffer[offs], &srcBuffer[offs], size ); + } + }// <-- EIP:48587 + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiLoadDefaults +// +// Description: function to load the default values +// +// Input: NVRAM_VARIABLE **varList, UINTN Mask +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS HiiLoadDefaults( NVRAM_VARIABLE **varList, UINTN Mask ) +{ + EFI_STATUS ReturnStatus = EFI_OUT_OF_RESOURCES; + EFI_STATUS Status; + NVRAM_VARIABLE *defaultVar = NULL; + UINT32 i = 0, index = 0; // EIP:48587 + UINT32 control; // EIP:48587 + + EFI_HII_VARIABLE_PACK_LIST *VariablePack = NULL; + + if ( ( varList == NULL ) /*|| ( *varList == NULL )*/ ) + return ReturnStatus; + + if( ( ! gVariables ) || ( gVariables->VariableCount == 0 ) ) // fatal error + while(1); + + *varList = EfiLibAllocateZeroPool( sizeof(NVRAM_VARIABLE) * gVariables->VariableCount ); + if ( *varList == NULL ) + return EFI_OUT_OF_RESOURCES; + + // Get the Current Values for defaults + defaultVar = ( NVRAM_VARIABLE * )*varList; + for ( i = 0; i < gVariables->VariableCount; i++, defaultVar++ ) + { + defaultVar->Buffer = VarGetNvram( i, &defaultVar->Size ); + } + + ReturnStatus = HiiInitializeProtocol(); + if ( EFI_ERROR( ReturnStatus ) ) + return ReturnStatus; + + ReturnStatus = EFI_SUCCESS; + for ( i = 0; i < gSetupCount - 1; i++ ) + { + Status = gHiiProtocol->GetDefaultImage( + gHiiProtocol, + (EFI_HII_HANDLE)(UINTN)gSetupHandles[i], + Mask, + &VariablePack + ); + + if ( EFI_ERROR( Status ) ) + { + continue; + } +// EIP:48587 + for ( ; index < gPages->PageCount; index++ ) + { + PAGE_INFO *pageInfo = (PAGE_INFO*)((UINT8 *)gPages + gPages->PageList[index]); + + if( pageInfo->PageHandle == NULL ) + { + continue; + } + + if( pageInfo->PageHandle != gSetupHandles[i] ) // EIP:48587 Find the end of current formset and go to next formset + break; + + for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ ) + { + CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]); + + if ( ( controlInfo->ControlVariable == VARIABLE_ID_LANGUAGE ) || ( controlInfo->ControlVariable == VARIABLE_ID_BOOT_ORDER ) || (controlInfo->ControlVariable == VARIABLE_ID_BBS_ORDER) ) + continue; + + if ( controlInfo->ControlDataWidth > 0 ) + { + VOID *ifrData = controlInfo->ControlPtr; + UINT32 ControlVarOffset; + + if ( ifrData == NULL ) + continue; + + ControlVarOffset = UefiGetQuestionOffset(ifrData); + + if ( VariablePack != NULL ) + _HiiParseVariablePack( VariablePack, ControlVarOffset, controlInfo->ControlVariable, controlInfo->ControlDataWidth, varList ); + } + } + } + MemFreePointer( (VOID **)&VariablePack ); + } +// EIP:48587 + + return ReturnStatus; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddControlToList +// +// Description: to add a control to list +// +// Input: CONTROL_INFO *NewControlInfo, UINT32 ControlSize +// +// Output: offset +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT32 AddControlToList(CONTROL_INFO *NewControlInfo, UINT32 ControlSize) +{ + UINT32 offset; + UINT32 u32Compensation; + + u32Compensation = (sizeof(UINT64) - (ControlSize%sizeof(UINT64))) % sizeof(UINT64); + + if((ControlListOffset + ControlSize + u32Compensation )> ControlListSize) + { + gControlInfo = MemReallocateZeroPool( gControlInfo, ControlListSize, ControlListSize + 4096 ); //Allocate 4k at a time + //Todo: introduce error case + ControlListSize+=4096; + } + + MemCopy((UINT8 *)gControlInfo + ControlListOffset, NewControlInfo, ControlSize); + + offset = ControlListOffset; + + ControlListOffset += (ControlSize + u32Compensation); + + return offset; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddPageToList +// +// Description: to add a page to list +// +// Input: PAGE_INFO *NewPageInfo, UINT32 PageSize +// +// Output: void +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID AddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize) +{ + UINT32 offset; + UINT32 ReallocSize=4096; + + if( PageInfoPtr == NULL ) //EIP48930 + PageInfoOffset = PageInfoSize = 0; + + if(PageInfoOffset + PageSize >= PageInfoSize) + { + if(ReallocSize < PageSize) + ReallocSize = (PageSize&0xFFFFF000) + 4096; + + PageInfoPtr = MemReallocateZeroPool( PageInfoPtr, PageInfoSize, PageInfoSize + ReallocSize ); //Allocate 4k at a time + //Todo: introduce error case + PageInfoSize+=ReallocSize; + } + + MemCopy((UINT8 *)PageInfoPtr + PageInfoOffset, NewPageInfo, PageSize); + + offset = PageInfoOffset; + + PageInfoOffset += PageSize; + + if(!PageListPtr) + { + PageListSize = 512; + PageListPtr = EfiLibAllocateZeroPool(PageListSize); + PageListPtr->PageCount = 1; //Leave space for offset of Page 0 + PageListPtr->PageList[PageListPtr->PageCount] = offset; + PageListPtr->PageCount++; + PageListOffset = sizeof(PAGE_LIST)+sizeof(UINT32); + } + else + { + if(PageListOffset + sizeof(UINT32) >= PageListSize) + { + PageListPtr = MemReallocateZeroPool(PageListPtr, PageListSize, PageListSize + 128); + PageListSize += 128; + } + PageListPtr->PageList[PageListPtr->PageCount] = offset; + PageListPtr->PageCount++; + PageListOffset += sizeof(UINT32); + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CreatePage +// +// Description: function used to create a page +// +// Input: PAGE_INFO **PageInfo, UINT32 *AllocatedSize, +// UINT32 *Offset, VOID *Buff, UINT32 BuffSize +// +// Output: void +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID CreatePage(PAGE_INFO **PageInfo, UINT32 *AllocatedSize, UINT32 *Offset, VOID *Buff, UINT32 BuffSize) +{ + + if(!(*AllocatedSize)) + { + //creating a new page + *PageInfo = EfiLibAllocateZeroPool(BuffSize); + *AllocatedSize = BuffSize; + MemCopy(*PageInfo, Buff, BuffSize); + + if((*PageInfo)->PageControls.ControlCount) + *Offset = BuffSize; + else //We have space to store one more offset + //*Offset = BuffSize - sizeof((*PageInfo)->PageControls.ControlList[0]); +// Fix the Issue with the Packing, Original code was not finding the correct Offset + *Offset = (UINT32)((UINTN)(&(*PageInfo)->PageControls.ControlList[0]) - (UINTN)(*PageInfo)); + + } + else + { + //adding offsets + if(*Offset + BuffSize >= *AllocatedSize) + { + *PageInfo = MemReallocateZeroPool( *PageInfo, *AllocatedSize, *AllocatedSize + 128 ); //Allocate 128 bytes at a time + //Todo: introduce error case + *AllocatedSize+=128; + } + MemCopy((UINT8 *)(*PageInfo) + *Offset, Buff, BuffSize); + + *Offset += BuffSize; + + (*PageInfo)->PageControls.ControlCount++; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MergePageListAndInfo +// +// Description: To merge the information +// +// Input: NIL +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID MergePageListAndInfo() +{ + UINTN i; + + gApplicationData = EfiLibAllocateZeroPool(PageListOffset + FirstPageOffset + PageInfoOffset); + gPages = (PAGE_LIST *) gApplicationData; + + MemCopy(gApplicationData, PageListPtr, PageListOffset); + MemCopy(gApplicationData + PageListOffset, FirstPage, FirstPageOffset); + MemCopy(gApplicationData + PageListOffset + FirstPageOffset, PageInfoPtr, PageInfoOffset); + + //Fix Offsets + i=0; + gPages->PageList[i] = PageListOffset; + i++; + + for(; i<gPages->PageCount; i++) + { + gPages->PageList[i] += (FirstPageOffset + PageListOffset); + } + + //Free Temp Memory + MemFreePointer(&FirstPage); + MemFreePointer(&PageInfoPtr); + MemFreePointer(&PageListPtr); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiMyGetStringLength +// +// Description: user function to get the string length +// +// Input: VOID* handle, UINT16 token +// +// Output: Length +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINTN HiiMyGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token ) +{ + CHAR16 *string; + UINTN length = 0; + + string = HiiGetString( handle, token ); + if ( string == NULL ) + return length; + + length = TestPrintLength( string ) / (NG_SIZE); + MemFreePointer( (VOID **)&string ); + + return length; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiMyGetMultiLineStringLength +// +// Description: returns Max length of the in the paragraph +// +// Input: Handle and token +// +// Output: Length +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +UINTN HiiMyGetMultiLineStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token ) +{ + CHAR16 *string; + UINTN length = 0,MaxLength=0; + UINTN i,j; + + string = HiiGetString( handle, token ); + if ( string == NULL ) + return length; + + i=j=0; + while(string[i]) + { + // is Newline + if((string[i]==0x0d)&& (string[i+1]==0x0a)) + { + string[i]=0x0; + length = TestPrintLength( &string[j] ) / (NG_SIZE); + if(length>MaxLength) + MaxLength = length; + i+=2; + j=i; + } + else + i++; + } + length = TestPrintLength( &string[j] ) / (NG_SIZE); + MemFreePointer( (VOID **)&string ); + + if(length>MaxLength) + MaxLength = length; + + return MaxLength; +} + + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: RTIfrProcessExit +// +// Description: Function to process ifr exit +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID RTIfrProcessExit(VOID) +{ + MemFreePointer(&gVariables); + VariableListPtr = NULL; + VariableInfoPtr = NULL; + VariableListOffset = VariableListSize = VariableInfoOffset = VariableInfoSize = 0; + + MemFreePointer(&gPageIdList); + PageIdListPtr = NULL; + PageIdInfoPtr = NULL; + PageIdListOffset = PageIdListSize = PageIdInfoOffset = PageIdInfoSize = 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: RTIfrProcessAddVarListAndPageIDList +// +// Description: Function to add var list page ID list +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID RTIfrProcessAddVarListAndPageIDList(VOID) +{ + UINT32 i; + + //Create Variable List + for(i=0; i < gToolVariables->VariableCount ; i++) + { + VARIABLE_INFO *VariableInfo; + + VariableInfo = (VARIABLE_INFO *)((UINT8 *)gToolVariables + gToolVariables->VariableList[i]); + + AddVariableToList(VariableInfo, sizeof(VARIABLE_INFO)); + } + + //Create Page ID list + for(i=0; i < gToolPageIdList->PageIdCount ; i++) + { + PAGE_ID_INFO *PageIdInfo; + + PageIdInfo = (PAGE_ID_INFO *)((UINT8 *)gToolPageIdList + gToolPageIdList->PageIdList[i]); + + AddPageIdToList(PageIdInfo, sizeof(PAGE_ID_INFO)); + } + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: RTIfrProcessFormIfUpdated +// +// Description: Fuction to process form if updated +// +// Input: UINT16 link +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN RTIfrProcessFormIfUpdated(UINT16 link) +{ + UINT32 j; + //Check if the page has changed during run time + for(j=0; j < gHpkInfoLength / sizeof(HPK_INFO); j++) + { + EFI_HII_PACK_HEADER *pack; + + if( + (gHpkInfo[j].Class == gSetupData[link].ClassID) && + (gHpkInfo[j].SubClass == gSetupData[link].SubClassID) + ) + { + pack = (EFI_HII_PACK_HEADER *)gSetupData[link].FormSet; + + if ( gHpkInfo[j].Length != pack->Length ) + break; + } + } + + if(j < gHpkInfoLength / sizeof(HPK_INFO)) + { + //This page changed during run time parse again + if(!gSetupData[link].Added) + AddDynamicForm(link); + return TRUE; + } + gSetupData[link].Added = 1; + + return FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: RTIfrProcessRunTimeForms +// +// Description: Function to process runtime forms +// +// Input: EFI_IFR_REF **ref +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID RTIfrProcessRunTimeForms(EFI_IFR_REF **ref) +{ + UINT32 i; + EFI_IFR_FORM_SET *formSet; + EFI_GUID DynamicPageGuid = DYNAMIC_PAGE_COUNT_GUID; + UINT16 count = 0; + + for(i = 0; i < gSetupCount - 1; i++) + { + if(!(gSetupData[i].Added)) + { + AddDynamicForm(i); + if((gSetupData[i].Added)) + { + formSet = HiiGetFormSet( i ); + (*ref)->Header.OpCode = EFI_IFR_REF_OP; + (*ref)->Header.Length = sizeof(EFI_IFR_REF); + (*ref)->Prompt = formSet->FormSetTitle; + (*ref)->Help = formSet->Help; + (*ref)++; + count++ ; + } + } + } + + gDynamicPageCount = count ; + + //Set Dynamic page count variable + VarSetNvramName( L"DynamicPageCount", &DynamicPageGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) ); + MergePageIdListAndInfo(); + MergeVariableListAndInfo(); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddPageIdToList +// +// Description: Function to add page id to list +// +// Input: PAGE_ID_INFO *NewPageIdInfo, UINT32 PageIdSize +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID AddPageIdToList(PAGE_ID_INFO *NewPageIdInfo, UINT32 PageIdSize) +{ + UINT32 offset; + + if( PageIdInfoPtr == NULL ) //EIP48930 + PageIdInfoOffset = PageIdInfoSize = 0; + + if(PageIdInfoOffset + PageIdSize >= PageIdInfoSize) + { + PageIdInfoPtr = MemReallocateZeroPool( PageIdInfoPtr, PageIdInfoSize, PageIdInfoSize + 256 ); //Allocate 4k at a time + //Todo: introduce error case + PageIdInfoSize+=256; + } + + MemCopy((UINT8 *)PageIdInfoPtr + PageIdInfoOffset, NewPageIdInfo, PageIdSize); + + offset = PageIdInfoOffset; + + PageIdInfoOffset += PageIdSize; + + if(!PageIdListPtr) + { + PageIdListSize = 128; + PageIdListPtr = EfiLibAllocateZeroPool(PageIdListSize); + PageIdListPtr->PageIdList[PageIdListPtr->PageIdCount] = offset; + PageIdListPtr->PageIdCount = 1; + PageIdListOffset = sizeof(PAGE_ID_LIST); + } + else + { + if(PageIdListOffset + sizeof(UINT32) >= PageIdListSize) + { + PageIdListPtr = MemReallocateZeroPool(PageIdListPtr, PageIdListSize, PageIdListSize + 128); + PageIdListSize += 128; + } + PageIdListPtr->PageIdList[PageIdListPtr->PageIdCount] = offset; + PageIdListPtr->PageIdCount++; + PageIdListOffset += sizeof(UINT32); + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MergePageIdListAndInfo +// +// Description: Function to merge page id list and info +// +// Input: NIL +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID MergePageIdListAndInfo() +{ + UINTN i; + + gPageIdList = EfiLibAllocateZeroPool(PageIdListOffset + PageIdInfoOffset); + + MemCopy(gPageIdList,PageIdListPtr,PageIdListOffset); + MemCopy(((UINT8 *)gPageIdList)+ PageIdListOffset,PageIdInfoPtr,PageIdInfoOffset); + + for(i=0; i<gPageIdList->PageIdCount; i++) + { + gPageIdList->PageIdList[i] += PageIdListOffset; + } + + gPageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[0]); + + //Free Temp Memory + MemFreePointer(&PageIdInfoPtr); + MemFreePointer(&PageIdListPtr); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddVariableToList +// +// Description: Function to add variable to list +// +// Input: VARIABLE_INFO *NewVariableInfo, UINT32 VariableSize +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID AddVariableToList(VARIABLE_INFO *NewVariableInfo, UINT32 VariableSize) +{ + UINT32 offset; + + if(VariableInfoOffset + VariableSize >= VariableInfoSize) + { + VariableInfoPtr = MemReallocateZeroPool( VariableInfoPtr, VariableInfoSize, VariableInfoSize + 256 ); //Allocate 4k at a time + //Todo: introduce error case + VariableInfoSize+=256; + } + + MemCopy((UINT8 *)VariableInfoPtr + VariableInfoOffset, NewVariableInfo, VariableSize); + + offset = VariableInfoOffset; + + VariableInfoOffset += VariableSize; + + if(!VariableListPtr) + { + VariableListSize = 128; + VariableListPtr = EfiLibAllocateZeroPool(VariableListSize); + VariableListPtr->VariableList[VariableListPtr->VariableCount] = offset; + VariableListPtr->VariableCount = 1; + VariableListOffset = sizeof(VARIABLE_LIST); + } + else + { + if(VariableListOffset + sizeof(UINT32) >= VariableListSize) + { + VariableListPtr = MemReallocateZeroPool(VariableListPtr, VariableListSize, VariableListSize + 128); + VariableListSize += 128; + } + VariableListPtr->VariableList[VariableListPtr->VariableCount] = offset; + VariableListPtr->VariableCount++; + if(VariableListPtr->VariableCount >= MAX_VARIABLE) + { + CHAR16 *Temp = L"Reached TSE Maximum supported variables"; + _DisplayErrorMessage(Temp); + ASSERT(0); + } + VariableListOffset += sizeof(UINT32); + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MergeVariableListAndInfo +// +// Description: Function to merge variable list and info +// +// Input: NIL +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID MergeVariableListAndInfo() +{ + UINTN i; + + gVariables = EfiLibAllocateZeroPool(VariableListOffset + VariableInfoOffset); + + MemCopy(gVariables,VariableListPtr,VariableListOffset); + MemCopy(((UINT8 *)gVariables)+ VariableListOffset,VariableInfoPtr,VariableInfoOffset); + + for(i=0; i<gVariables->VariableCount; i++) + { + gVariables->VariableList[i] += VariableListOffset; + } + + //Free Temp Memory + MemFreePointer(&VariableInfoPtr); + MemFreePointer(&VariableListPtr); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetSubFormCount +// +// Description: function to count the subform and Ref inside the formset. +// +// Input: UINT8 *buff - Pointer to form to search for links to other forms +// +// Output: count - no of subforms +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +UINTN GetSubFormCount(UINT8 *buff) +{ + UINTN *tmpFormIDBuf; + UINTN MaxPagecount=100; + UINTN PageCount= 0; + UINTN i=0, j=0, found =0; + EFI_IFR_OP_HEADER *Header; + + tmpFormIDBuf = (UINTN*)EfiLibAllocateZeroPool(MaxPagecount*sizeof(UINTN)); + //go thru the forms and get the links, creating the lookup table also + do + { + Header = (EFI_IFR_OP_HEADER*)(buff+i); + switch(Header->OpCode ) + { + case EFI_IFR_FORM_OP: // find parent in lookup table and then the parent pageNum to link + // Add page if is not in lookup table already + found=0; + j=0; + + while( (found==0) && ( j < PageCount ) ){ + if(tmpFormIDBuf[j] == ((EFI_IFR_FORM*)Header)->FormId ) + { + found =1; + break; + } + j++; + } + + if(!found) + { + // pages in the root(no parent) + tmpFormIDBuf[PageCount] = ((EFI_IFR_FORM*)Header)->FormId ; + PageCount++; + } + + break; + + case EFI_IFR_REF_OP: // add to lookup table adding the PageID and ParentPageID + // Add page if is not in lookup table already + found=0; + j=0; + + while( (found==0) && ( j < PageCount ) ){ + if(tmpFormIDBuf[j] == ((EFI_IFR_FORM*)Header)->FormId ) + { + found =1; + } + j++; + } + + if(!found) + { + // pages in the root(no parent) + tmpFormIDBuf[PageCount] = ((EFI_IFR_FORM*)Header)->FormId ; + PageCount++; + } + break; + + default: + break; + } + // If the Buffer is not enough the reallocate more + if(PageCount >= MaxPagecount) + { + UINTN *tmpBuf; + MaxPagecount +=50; + tmpBuf = (UINTN*)EfiLibAllocateZeroPool(MaxPagecount*sizeof(UINTN)); + MemCopy(tmpBuf,tmpFormIDBuf,sizeof(UINTN)*PageCount); + MemFreePointer(&tmpFormIDBuf); + tmpFormIDBuf = tmpBuf; + } + + i+=Header->Length; + }while(Header->OpCode != EFI_IFR_END_FORM_SET_OP); + + MemFreePointer(&tmpFormIDBuf); + return PageCount; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: InitFormsetLinks +// +// Description: Function to init formset links +// +// Input: char *buff, UINTN InitFormNum +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID InitFormsetLinks(char *buff,UINTN InitFormNum) +{ + UINTN i=0, j=0, found =0,InitForm=InitFormNum; + EFI_IFR_OP_HEADER *Header; + UINTN count = 0; +///EIP:24060 - Start + UINT16 RootPageinFormSet=0; +///EIP:24060 - End + + // allocate memory for data + if(FSetLinks != NULL) + MemFreePointer(&FSetLinks); + + count = GetSubFormCount(buff); + FSetLinks = (FormSetLinks*)EfiLibAllocateZeroPool(sizeof(FormSetLinks) + count * sizeof(PageLink)); + + //go thru the forms and get the links, creating the lookup table also + do + { + Header = (EFI_IFR_OP_HEADER*)(buff+i); + switch(Header->OpCode ) + { + case EFI_IFR_FORM_OP: // find parent in lookup table and then the parent pageNum to link + + // Add page if is not in lookup table already + found=0; + j=0; + + while( (found==0) && ( j < FSetLinks->PageCount ) ){ + if(FSetLinks->PageLink[j].FormID == ((EFI_IFR_FORM*)Header)->FormId ) + { + FSetLinks->PageLink[j].PageNum = (UINT16)InitForm++; + found =1; + break; + } + j++; + } + + if(!found) + { +///EIP:24060 - Start + if(!RootPageinFormSet) + RootPageinFormSet = ((EFI_IFR_FORM*)Header)->FormId; +///EIP:24060 - End + // pages in the root(no parent) + FSetLinks->PageLink[FSetLinks->PageCount].FormID = ((EFI_IFR_FORM*)Header)->FormId ; + + if(IsOrphanPagesAsRootPage()) + { + FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0; + } + else + { + if(RootPageinFormSet == ((EFI_IFR_FORM*)Header)->FormId) + FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0; + else + FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = FSetLinks->PageLink[0].PageNum; + } + + FSetLinks->PageLink[FSetLinks->PageCount].PageNum = (UINT16)InitForm++; + FSetLinks->PageCount++; + } + + break; + + case EFI_IFR_REF_OP: // add to lookup table adding the PageID and ParentPageID + // Add page if is not in lookup table already + found=0; + j=0; + + while( (found==0) && ( j < FSetLinks->PageCount ) ){ + if(FSetLinks->PageLink[j].FormID == ((EFI_IFR_FORM*)Header)->FormId ) + { +///EIP:24060 - Start + if(RootPageinFormSet != FSetLinks->PageLink[j].FormID) + if(FSetLinks->PageLink[j].PageNum != (UINT16)InitForm-1) // Parent of the Page can't be same page id. + FSetLinks->PageLink[j].ParentPageID = (UINT16)InitForm-1; + + +///EIP:24060 - End + found =1; + } + j++; + } + + if(!found) + { + // sub pages + FSetLinks->PageLink[FSetLinks->PageCount].FormID = ((EFI_IFR_FORM*)Header)->FormId ; + FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = (UINT16)InitForm-1; + FSetLinks->PageLink[FSetLinks->PageCount].PageNum = 0; + FSetLinks->PageCount++; + } + break; + + default: + + break; + + } + i+=Header->Length; + }while(Header->OpCode != EFI_IFR_END_FORM_SET_OP); + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetPageParent +// +// Description: Function to get parent page +// +// Input: int PageNum +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 GetPageParent(int PageNum) +{ + UINT16 i=0; + + do{ + if(FSetLinks->PageLink[i].PageNum == PageNum ) + { + return (FSetLinks->PageLink[i].ParentPageID ); + break; + } + }while( i++ < FSetLinks->PageCount ); + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetPageIdIndex +// +// Description: To get the index of a perticular page +// +// Input: EFI_GUID * FormGuid, UINT16 FormClass, UINT16 FormSubClass +// +// Output: PageIndex +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 GetPageIdIndex(EFI_GUID * FormGuid, UINT16 FormClass, UINT16 FormSubClass) +{ + UINT16 i; + PAGE_ID_INFO *PageId; + + if(PageIdListPtr == NULL) + PageIdListPtr = EfiLibAllocateZeroPool(128); + + //search if this combination exists + for(i = 0; i < PageIdListPtr->PageIdCount ; i++) + { + PageId = (PAGE_ID_INFO *) ((UINT8 *)PageIdInfoPtr + PageIdListPtr->PageIdList[i]); + if( EfiCompareGuid(FormGuid,&(PageId->PageGuid)) )//Compare Guid + { + if(FormClass == PageId->PageClass)//Compare class + { + if(FormSubClass == PageId->PageSubClass)//Compare SubClass + { + break; //found entry + } + } + } + } + + if(i >= PageIdListPtr->PageIdCount) + { + PAGE_ID_INFO NewPageId; + + MemCopy(&(NewPageId.PageGuid),FormGuid,sizeof(EFI_GUID)); + NewPageId.PageClass = FormClass; + NewPageId.PageSubClass = FormSubClass; + + i = (UINT16)PageIdListPtr->PageIdCount; + AddPageIdToList(&NewPageId, sizeof(PAGE_ID_INFO)); + } + + return i; + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddVariable +// +// Description: Function to add variable +// +// Input: EFI_IFR_VARSTORE *Varstore +// +// Output: success +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +int AddVariable(EFI_IFR_VARSTORE *Varstore) +{ + UINT16 i=0; + UINTN varfound=0; + char *str2; + EFI_GUID *GUID = &(Varstore->Guid); + VARIABLE_INFO *Variable; + UINT16 VarName[40]; + PVAR_KEY_TABLE pVarTable; + + + str2= (char*)((UINT8*)Varstore +sizeof(EFI_IFR_VARSTORE)); //name + + //Convert to unicode string + MemSet(VarName, sizeof(VarName), 0); + + i = 0; + while(*str2) + { + VarName[i] = *str2; + i++; + str2++; + } + + + // check that the variable is not already in the list + + + for(i=0; i < VariableListPtr->VariableCount; i++) + { + Variable = (VARIABLE_INFO *) ((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList[i]); + if( EfiCompareGuid(GUID,&(Variable->VariableGuid)) )//Compare Guid + if(EfiStrCmp(VarName,Variable->VariableName) ==0) + { + varfound=1; + Variable->VariableID = Varstore->VarId; + break; + } + } + + if(!varfound) + { + VARIABLE_INFO NewVariable; + + MemSet(&NewVariable,sizeof(VARIABLE_INFO),0); + NewVariable.VariableID = Varstore->VarId; + MemCopy((&NewVariable.VariableGuid),&(Varstore->Guid),sizeof(EFI_GUID)); + NewVariable.VariableAttributes = 7; + EfiStrCpy(NewVariable.VariableName,VarName); + + AddVariableToList(&NewVariable, sizeof(VARIABLE_INFO)); + } + + pVarTable = &VarKeyTable; + + while(pVarTable->Next) + pVarTable = pVarTable->Next; + + pVarTable->Next = EfiLibAllocateZeroPool(sizeof(VAR_KEY_TABLE)); + pVarTable = pVarTable->Next; + + pVarTable->VarId = Varstore->VarId; + pVarTable->Index = i; + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetVarNumFromVarID +// +// Description: Function to get variable number from var ID +// +// Input: UINT32 ID +// +// Output: Variable Index +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT32 GetVarNumFromVarID(UINT32 ID) +{ + PVAR_KEY_TABLE pVarTable; + + pVarTable = VarKeyTable.Next; + + while(pVarTable) + { + if(pVarTable->VarId == ID) + return(pVarTable->Index); + pVarTable = pVarTable->Next; + } + + return 0; + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CleanVarKeyTable +// +// Description: To clear the key table specific buffers +// +// Input: NIL +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID CleanVarKeyTable() +{ + PVAR_KEY_TABLE pVarTable; + + pVarTable = VarKeyTable.Next; + + while(pVarTable) + { + VarKeyTable.Next = pVarTable->Next; + MemFreePointer(&pVarTable); + pVarTable = VarKeyTable.Next; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddFormSetVariable +// +// Description: +// +// Input: EFI_GUID * VarGuid +// +// Output: VarCount +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT32 AddFormSetVariable(EFI_GUID * VarGuid) +{ + VARIABLE_INFO Variable; + UINT32 i; + + Variable.VariableID = 0; + MemCopy((&Variable.VariableGuid),VarGuid,sizeof(EFI_GUID)); + Variable.VariableAttributes = 0x7; // BT+RT+NV + EfiStrCpy(Variable.VariableName,L"Setup"); + + i = VariableListPtr->VariableCount; + AddVariableToList(&Variable, sizeof(VARIABLE_INFO)); + + return i; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: IsVarGuidPresent +// +// Description: +// +// Input: EFI_GUID * VarGuid, int * Index +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +int IsVarGuidPresent(EFI_GUID * VarGuid, int * Index) +{ + UINT32 i=0; + VARIABLE_INFO *Variable; + + for(i=0; i < VariableListPtr->VariableCount; i++) + { + Variable = (VARIABLE_INFO *) ((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList[i]); + if( EfiCompareGuid(VarGuid,&(Variable->VariableGuid)) )//Compare Guid + if( (EfiStrCmp(L"Setup",Variable->VariableName) ==0) || + (EfiStrCmp(L"setup",Variable->VariableName) ==0 )) + { + *Index = i; + return 1; + } + } + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddDynamicForm +// +// Description: +// +// Input: UINT32 HiiIndex +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID AddDynamicForm(UINT32 HiiIndex) +{ + EFI_HII_PACK_HEADER *fset; + EFI_IFR_FORM_SET *Formset; + EFI_IFR_FORM *form; + + UINTN x, i=0; + UINT8 *buff = NULL; + + CONTROL_INFO controlInfo; + UINT32 ControlOffset; + UINT32 VarIndex; + + PVAR_KEY_TABLE pVarTable; + + UINT32 AllocatedPageSize , PageOffset; + PAGE_INFO *NewPageInfo; + + PAGE_INFO TempPage; + + x = gSetupData[HiiIndex].FormSetLength; + buff = (UINT8 *) gSetupData[HiiIndex].FormSet; + fset = (EFI_HII_PACK_HEADER *)buff; + + + while(i<x) // Look for formsets + { + Formset = (EFI_IFR_FORM_SET *) ((UINTN)fset + sizeof(EFI_HII_PACK_HEADER)); + + if((fset->Type == FORM_SUBCLASS) && (Formset->Header.OpCode == EFI_IFR_FORM_SET_OP )) + { + if(EFI_IFR_END_FORM_SET_OP == *(buff + sizeof(EFI_HII_PACK_HEADER) + sizeof(EFI_IFR_FORM_SET))) + { + // This package has no forms. Processing this further will result in unpredictability. + break; + } + + gSetupData[HiiIndex].Added = 1; + + CtrlVar=0,CtrlCondVar=0; // initialize control variables for every formset + ActualCondVar =0; ActualCondVar2=0; + CtrlCondVar2=0; // this should not be necessary if vfr compiler would start + + // Check the GUID is updated in the Variable list or not + VarIndex = 0; + if(IsVarGuidPresent(&(Formset->Guid), &VarIndex)) + CtrlVar = CtrlCondVar = CtrlCondVar2 = ActualCondVar = ActualCondVar2 = VarIndex; + else + CtrlVar = CtrlCondVar = CtrlCondVar2 = ActualCondVar = ActualCondVar2 = AddFormSetVariable(&(Formset->Guid)); + + pVarTable = &VarKeyTable; + + while(pVarTable->Next) + pVarTable = pVarTable->Next; + + pVarTable->Next = EfiLibAllocateZeroPool(sizeof(VAR_KEY_TABLE)); + pVarTable = pVarTable->Next; + + pVarTable->VarId = 0; + pVarTable->Index = (UINT16)CtrlVar; + + // with a varstote select/select_pair at the beginning of a formset + + i= sizeof(EFI_HII_PACK_HEADER) + sizeof(EFI_IFR_FORM_SET); + form =(EFI_IFR_FORM*)(buff+i ); + + // create the pages lookup table + InitFormsetLinks((char*)form, PageListPtr ? PageListPtr->PageCount:1); + + // add NULL control above submenu in main + ControlOffset = 0; + CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, &ControlOffset, sizeof(UINT32)); + + // add second null control for splitting the page in 2 halves + if (TotalRootPages == 7) + { + ControlOffset = 0; + CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, &ControlOffset, sizeof(UINT32)); + } + + // add the submenu control to main form that points to this form. + controlInfo.ControlHandle = gSetupData[HiiIndex].Handle; + controlInfo.ControlVariable = 0; + controlInfo.ControlConditionalVariable[0] = 0; + controlInfo.ControlConditionalVariable[1] = 0; + controlInfo.ControlType = CONTROL_TYPE_SUBMENU; + controlInfo.ControlPageID = 0; + controlInfo.ControlDestPageID = PageListPtr ? ((UINT16)PageListPtr->PageCount):1 ; + + controlInfo.ControlFlags.ControlVisible = 1; + controlInfo.ControlFlags.ControlAccess = 0; + controlInfo.ControlFlags.ControlReadOnly = 0; + controlInfo.ControlFlags.ControlReset = 0; + controlInfo.ControlFlags.Reserved1 = 0; + controlInfo.ControlFlags.ControlRefresh = 0; + controlInfo.ControlFlags.Reserved2 = 0; + + + controlInfo.ControlHelp = 0; + controlInfo.ControlLabel = 0; + controlInfo.ControlIndex = 0; + controlInfo.ControlLabelCount = 0; + controlInfo.ControlPtr = (VOID*)((UINTN)gSetupData[HiiIndex].FormSet + + sizeof(EFI_HII_PACK_HEADER) + + sizeof(EFI_IFR_FORM_SET) + + TotalRootPages * sizeof(EFI_IFR_REF)); + controlInfo.ControlConditionalPtr = 0; + controlInfo.ControlDataLength = 0; + controlInfo.ControlDataWidth = 0; + controlInfo.QuestionId = 0; + + ControlOffset = AddControlToList(&controlInfo, sizeof(CONTROL_INFO)); + CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, &ControlOffset, sizeof(UINT32)); + + TotalRootPages++; + + // add forms + while(i<x) + { + while((UINT8)*(buff+i) != EFI_IFR_FORM_OP) + { + if((UINT8)*(buff+i) == EFI_IFR_VARSTORE_OP) + AddVariable((EFI_IFR_VARSTORE*)(buff+i)); + i+= (UINT8)*(buff+i+1); + + } + + form =(EFI_IFR_FORM*)(buff+i ); + + AllocatedPageSize = PageOffset = 0; + NewPageInfo = NULL; + + TempPage.PageHandle = gSetupData[HiiIndex].Handle; + TempPage.PageIdIndex = GetPageIdIndex(&(Formset->Guid), Formset->Class, Formset->SubClass); + TempPage.PageFormID = form->FormId; + TempPage.PageTitle = (UINT16)0; + TempPage.PageSubTitle = form->FormTitle; + TempPage.PageID = PageListPtr ? ((UINT16) PageListPtr->PageCount):1; + TempPage.PageParentID = PageListPtr ? GetPageParent(PageListPtr->PageCount):0; + + TempPage.PageFlags.PageVisible = 0; + TempPage.PageFlags.PageHelpVisible = 0; + TempPage.PageFlags.PageDisableHotKeys = 0; + TempPage.PageFlags.Reserved = 0; + + TempPage.PageVariable = 0; + TempPage.PageControls.ControlCount = 0; + TempPage.PageControls.ControlList[0] = 0; + + //Check for Dynamic Page Flag + if (TempPage.PageParentID == 0 && IsGroupDynamicPages()) //PageParentID is 0 && SDL token is true + { + //then set as dynamic page + TempPage.PageFlags.PageDynamic = TRUE ; + TempPage.PageFlags.PageVisible = TRUE; + + } + + // memory for TempPage.PageControls.ControlList[0] will be allocated later when adding controls + CreatePage(&NewPageInfo, &AllocatedPageSize, &PageOffset, &TempPage, sizeof(PAGE_INFO)); + + i += AddHpkControls(HiiIndex,(buff + i),x-i,&NewPageInfo, &AllocatedPageSize, &PageOffset); + + AddPageToList(NewPageInfo, PageOffset); + if(NewPageInfo->PageControls.ControlCount >= MAX_CONTROLS) + { + CHAR16 *Temp = L"Reached TSE Maximum supported Controls"; + _DisplayErrorMessage(Temp); + ASSERT(0); + } + + MemFreePointer(&NewPageInfo); + + if( *((char*)buff +i) == EFI_IFR_END_FORM_SET_OP) + { + controllabel = controlindex = 0; + if(FSetLinks !=NULL) + { + MemFreePointer(&FSetLinks); + FSetLinks = NULL; + } + i+=2; // add the end_formset opcode size + break; //no more forms in this formset... + } + } + } + else // package is NOT EFI_HII_IFR + { + //go to next package + i += fset->Length ; + } + } // end of while loop + + CleanVarKeyTable(); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetHelpToken +// +// Description: +// +// Input: UINT8 *ifr +// +// Output: token +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 GetHelpToken( UINT8 *ifr ) +{ + EFI_IFR_OP_HEADER *headerPtr = (EFI_IFR_OP_HEADER *)ifr; + UINT16 token = 0; + + switch ( headerPtr->OpCode ) + { + case EFI_IFR_TEXT_OP: + { + EFI_IFR_TEXT *ptr = (EFI_IFR_TEXT *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_ORDERED_LIST_OP: + { + EFI_IFR_ORDERED_LIST *ptr = (EFI_IFR_ORDERED_LIST *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_ONE_OF_OP: + { + EFI_IFR_ONE_OF *ptr = (EFI_IFR_ONE_OF *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_CHECKBOX_OP: + { + EFI_IFR_CHECK_BOX *ptr = (EFI_IFR_CHECK_BOX *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_DATE_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_NUMERIC_OP: + { + EFI_IFR_NUMERIC *ptr = (EFI_IFR_NUMERIC *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_PASSWORD_OP: + { + EFI_IFR_PASSWORD *ptr = (EFI_IFR_PASSWORD *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_REF_OP: + { + EFI_IFR_REF *ptr = (EFI_IFR_REF *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_STRING_OP: + { + EFI_IFR_STRING *ptr = (EFI_IFR_STRING *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_SAVE_DEFAULTS_OP: + { + EFI_IFR_SAVE_DEFAULTS *ptr = (EFI_IFR_SAVE_DEFAULTS *)headerPtr; + token = ptr->Help; + } + break; + case EFI_IFR_INVENTORY_OP: + { + EFI_IFR_INVENTORY *ptr = (EFI_IFR_INVENTORY *)headerPtr; + token = ptr->Help; + } + break; + default: + break; + } + + return token; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetQuestionToken +// +// Description: +// +// Input: UINT8 *ifr +// +// Output: token +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 GetQuestionToken( UINT8 *ifr ) +{ + EFI_IFR_OP_HEADER *headerPtr = (EFI_IFR_OP_HEADER *)ifr; + UINT16 token = 0; + + switch ( headerPtr->OpCode ) + { + case EFI_IFR_TEXT_OP: + { + EFI_IFR_TEXT *ptr = (EFI_IFR_TEXT *)headerPtr; + token = ptr->Text; + } + break; + case EFI_IFR_ONE_OF_OP: + { + EFI_IFR_ONE_OF *ptr = (EFI_IFR_ONE_OF *)headerPtr; + token = ptr->Prompt; + } + break; + case EFI_IFR_CHECKBOX_OP: + { + EFI_IFR_CHECK_BOX *ptr = (EFI_IFR_CHECK_BOX *)headerPtr; + token = ptr->Prompt; + } + break; + case EFI_IFR_DATE_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_NUMERIC_OP: + { + EFI_IFR_NUMERIC *ptr = (EFI_IFR_NUMERIC *)headerPtr; + token = ptr->Prompt; + } + break; + case EFI_IFR_PASSWORD_OP: + { + EFI_IFR_PASSWORD *ptr = (EFI_IFR_PASSWORD *)headerPtr; + token = ptr->Prompt; + } + break; + case EFI_IFR_REF_OP: + { + EFI_IFR_REF *ptr = (EFI_IFR_REF *)headerPtr; + token = ptr->Prompt; + } + break; + case EFI_IFR_STRING_OP: + { + EFI_IFR_STRING *ptr = (EFI_IFR_STRING *)headerPtr; + token = ptr->Prompt; + } + break; + case EFI_IFR_SAVE_DEFAULTS_OP: + { + EFI_IFR_SAVE_DEFAULTS *ptr = (EFI_IFR_SAVE_DEFAULTS *)headerPtr; + token = ptr->Prompt; + } + break; + case EFI_IFR_INVENTORY_OP: + { + EFI_IFR_INVENTORY *ptr = (EFI_IFR_INVENTORY *)headerPtr; + token = ptr->Text; + } + break; + case EFI_IFR_SUBTITLE_OP: + { + EFI_IFR_SUBTITLE *ptr = (EFI_IFR_SUBTITLE *)headerPtr; + token = ptr->SubTitle; + } + break; + default: + break; + } + + return token; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetPageNumFromFormID +// +// Description: +// +// Input: UINTN FormID +// +// Output: PageNum +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 GetPageNumFromFormID(UINTN FormID) +{ + UINTN i=0; + + do{ + if(FSetLinks->PageLink[i].FormID == FormID ) + { + return (FSetLinks->PageLink[i].PageNum ); + break; + } + }while( i++ < FSetLinks->PageCount ); + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: Updatedefaults +// +// Description: Function to update defsaults +// +// Input: VOID *Data, UINT16 *size, VOID *Failsafe, VOID *Optimal, +// struct _CONTROL_FLAGS *ControlFlags +// +// Output: void +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID Updatedefaults( VOID *Data, UINT16 *size, VOID *Failsafe, VOID *Optimal, struct _CONTROL_FLAGS *ControlFlags) +{ + + UINT8 Flags=0; + UINTN i=0; + + + switch( *((UINT8*)Data) ) + { + // ------ text -------------- + case EFI_IFR_TEXT_OP: //(only interactive) + Flags =((EFI_IFR_TEXT*)Data)->Flags; + + if(Flags & EFI_IFR_FLAG_INTERACTIVE) + { + + ControlFlags->ControlRefresh = DEFAULT_REFRESH_RATE; + + } + + if(Flags & EFI_IFR_FLAG_RESET_REQUIRED) + ControlFlags->ControlReset = 1; + break; + + // ------ ref -------------- + case EFI_IFR_REF_OP: // uses only interactive , but to signal that a key has to be passed + break; // back to a consumer (this behavior is not defined in TSE as of 5/20/05) + + // ------ one of -------------- + case EFI_IFR_ONE_OF_OP: + + i= sizeof(EFI_IFR_ONE_OF); + do{ + Flags =((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Flags; + + if(Flags & EFI_IFR_FLAG_INTERACTIVE) + ControlFlags->ControlRefresh = DEFAULT_REFRESH_RATE; + + if(Flags & EFI_IFR_FLAG_RESET_REQUIRED) + ControlFlags->ControlReset = 1; + + if(Flags & EFI_IFR_FLAG_DEFAULT) + { + *(UINT16*)Optimal = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value; + *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width; + } + + if(Flags & EFI_IFR_FLAG_MANUFACTURING ) + { + *(UINT16*)Failsafe = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value; + *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width; + } + + i+=sizeof(EFI_IFR_ONE_OF_OPTION); + + }while(((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Header.OpCode != EFI_IFR_END_ONE_OF_OP); + break; + + // ------ checkbox -------------- + case EFI_IFR_CHECKBOX_OP: + + Flags = ((EFI_IFR_CHECK_BOX*) Data)->Flags ; + + if(Flags & EFI_IFR_FLAG_RESET_REQUIRED) + ControlFlags->ControlReset = 1; + + *size = (UINT16)((EFI_IFR_CHECK_BOX*)Data)->Width /*1*/; + *(UINT16*)Optimal = 0; + *(UINT16*)Failsafe = 0; + if (((EFI_IFR_CHECK_BOX*) Data)->Flags & EFI_IFR_FLAG_DEFAULT) { + *(UINT16*)Optimal = 1; + } + if (((EFI_IFR_CHECK_BOX*) Data)->Flags & EFI_IFR_FLAG_MANUFACTURING) { + *(UINT16*)Failsafe = 1; + } + + ControlFlags->ControlRefresh=0; + break; + + // ------ numeric -------------- + case EFI_IFR_NUMERIC_OP: + ControlFlags->ControlRefresh=0; + + Flags = ((EFI_IFR_CHECK_BOX*) Data)->Flags ; + + if(Flags & EFI_IFR_FLAG_RESET_REQUIRED) + ControlFlags->ControlReset = 1; + + // note: width is defined, but default entry is UINT16 in structure. + *size = ((EFI_IFR_NUMERIC*)Data)->Width/*2*/; + *(UINT16*)Optimal = ((EFI_IFR_NUMERIC*)Data)->Default; + + *(UINT16*)Failsafe = ((EFI_IFR_NUMERIC*)Data)->Default; + + break; + + // ------ ordered list -------------- + case EFI_IFR_ORDERED_LIST_OP: + i= sizeof(EFI_IFR_ORDERED_LIST); + do{ + Flags =((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Flags; + + if(Flags & EFI_IFR_FLAG_INTERACTIVE) + ControlFlags->ControlRefresh = DEFAULT_REFRESH_RATE; + + if(Flags & EFI_IFR_FLAG_RESET_REQUIRED) + ControlFlags->ControlReset = 1; + + if(Flags & EFI_IFR_FLAG_DEFAULT) + { + *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width/*2*/; + *(UINT16*)Optimal = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value; + } + + if(Flags & EFI_IFR_FLAG_MANUFACTURING ) + { + *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width/*2*/; + *(UINT16*)Failsafe = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value; + } + + i+=sizeof(EFI_IFR_ONE_OF_OPTION); + + }while(((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Header.OpCode != EFI_IFR_END_ONE_OF_OP); + break; + + + // ------ date -------------- + case EFI_IFR_DATE_OP: + ControlFlags->ControlRefresh = DEFAULT_DATETIME_REFRESH; + break; + + // ------ time -------------- + case EFI_IFR_TIME_OP: + ControlFlags->ControlRefresh = DEFAULT_DATETIME_REFRESH; + break; + + case EFI_IFR_STRING_OP: + Flags = ((EFI_IFR_STRING*) Data)->Flags; + + if(Flags & EFI_IFR_FLAG_RESET_REQUIRED) + ControlFlags->ControlReset = 1; + break; + + case EFI_IFR_PASSWORD_OP: + Flags = ((EFI_IFR_STRING*) Data)->Flags; + + if(Flags & EFI_IFR_FLAG_RESET_REQUIRED) + ControlFlags->ControlReset = 1; + break; + + default: + break; + + } + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: AddHpkControls +// +// Description: +// +// Input: UINT32 HiiIndex, UINT8 *buff,UINTN size, PAGE_INFO **NewPageInfo, +// UINT32 *AllocatedPageSize, UINT32 *PageOffset +// +// Output: UINTN +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINTN AddHpkControls(UINT32 HiiIndex, UINT8 *buff,UINTN size, PAGE_INFO **NewPageInfo, UINT32 *AllocatedPageSize, UINT32 *PageOffset) +{ + UINTN i =0 , end=0,j=0; + UINTN ConditionalPtr=0, ControlPtr = 0; + UINT16 DestPageID =0xFFFF, ControlType=0, QuestionId = 0, HelpOffset=0, OpcodeNum = 0; + BOOLEAN AddControl = TRUE; + struct _CONTROL_FLAGS ControlFlags ; + UINTN CtrlFailSafe = 0, CtrlOptimal = 0; + UINT16 Defaults_size=0; + EFI_IFR_OP_HEADER *Hdr; + + UINT32 ControlSize; + UINT32 ControlOffset; + CONTROL_INFO *NewControlInfo; + + + // for loop for the number of controls of this + while(i < size ) + { + CtrlFailSafe = 0; + CtrlOptimal = 0; + + MemSet( &ControlFlags, sizeof(CONTROL_FLAGS), 0 ); //reset all the flags to zero + ControlFlags.ControlVisible =0x1; +/* ControlFlags.ControlAccess =0; + ControlFlags.ControlRefresh =0; + ControlFlags.ControlReset =0; + ControlFlags.Reserved1 =0; + ControlFlags.Reserved2 =0; +*/ + + // control type + switch(*(buff +i)) + { + case EFI_IFR_END_FORM_OP: + controlindex++; + end =1; + break; + + default : + if( *(buff +i) == EFI_IFR_LABEL_OP) + { + UINT8 *tBuff; + controllabel ++; + controlindex=0; + + tBuff = (buff +i+ *(buff+i+1)); + OpcodeNum=0; + + while( (*tBuff != EFI_IFR_LABEL_OP ) && (*tBuff != EFI_IFR_END_FORM_SET_OP) ) + { + tBuff = tBuff +(unsigned long)*(tBuff+1); + OpcodeNum++; + }; + } + + ControlType = controltypes[*(buff +i) -1]; + HelpOffset = GetHelpToken( buff + i ); + QuestionId = GetQuestionToken( buff + i ); + + // check if it is + switch(ControlType) + { + case CONTROL_TYPE_MEMO: + break; + + case CONTROL_TYPE_SUBMENU: + DestPageID = GetPageNumFromFormID(((EFI_IFR_REF*)((char*)buff +i))->FormId); + break; + + case CONTROL_TYPE_CHECKBOX: + ControlType = CONTROL_TYPE_POPUPSEL; // With no DestPageID + break; + + case CONTROL_TYPE_POPUPSEL: + break; + + case CONTROL_TYPE_TEXT: + break; + + + case CONTROL_TYPE_ORDERED_LIST: + break; + + case END_EVAL_IF: // ENDIF for grayout,suppress or inconsistent + ConditionalPtr = 0; + updatecondvars =1; + + AddControl = FALSE; + break; + + case CONTROL_TYPE_TIME: + break; + + case CONTROL_TYPE_DATE: + break; + + case CONTROL_TYPE_VARSTORE: + AddVariable((EFI_IFR_VARSTORE*)(buff+i)); + AddControl =FALSE; + break; + + case CONTROL_TYPE_VARSTORE_SELECT: + CtrlVar= ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT*)((char*)buff +i))->VarId); + AddControl =FALSE; + break; + + case CONTROL_TYPE_VARSTORE_SELECT_PAIR: + CtrlVar= ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)buff +i))->VarId); + ActualCondVar2 = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)buff +i))->SecondaryVarId); + AddControl =FALSE; + break; + + + case INCONSISTENT_IF: + case START_EVAL_IF: // IF for grayout,suppress or inconsistent + + + if(updatecondvars == 1) + { + Hdr= (EFI_IFR_OP_HEADER*) (buff+i); + Hdr = (EFI_IFR_OP_HEADER*)((UINT8*)Hdr+Hdr->Length); + // special case if there is a varstore just after the IF + switch(Hdr->OpCode) + { + case EFI_IFR_VARSTORE_SELECT_OP: + ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT*)((char*)Hdr))->VarId); + break; + case EFI_IFR_VARSTORE_SELECT_PAIR_OP: + ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)Hdr))->VarId); + ActualCondVar2 = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)Hdr))->SecondaryVarId); + break; + + } + + // save CtrlcondVars + CtrlCondVar = ActualCondVar; + CtrlCondVar2 = ActualCondVar2; + updatecondvars = 0; + ConditionalPtr = (UINTN)buff+i; + + } + + if(ControlType == INCONSISTENT_IF) + { + AddControl = TRUE; + break; + } + + //break; break not used on purpose + + case 0: // if is not a known control, then go to next control + AddControl = FALSE; + break; + + + } + break; + } + + if(end ==1) + break; + + if(AddControl) + { + Defaults_size =0; + Updatedefaults( (void *)(buff + i) , &Defaults_size, &CtrlFailSafe, &CtrlOptimal, &ControlFlags); + + ControlSize = sizeof(CONTROL_INFO) + Defaults_size * 2; + + NewControlInfo = EfiLibAllocateZeroPool(ControlSize); + + ControlPtr = (UINTN)buff+i; + + if(ControlType == INCONSISTENT_IF) + { + ControlType = CONTROL_TYPE_MSGBOX; + ControlPtr = 0; + } + + NewControlInfo->ControlHandle = gSetupData[HiiIndex].Handle; + NewControlInfo->ControlVariable = CtrlVar; + NewControlInfo->ControlConditionalVariable[0] = CtrlCondVar; + NewControlInfo->ControlConditionalVariable[1] = CtrlCondVar2; + NewControlInfo->ControlType = ControlType & CONTROL_TYPE_MASK; + NewControlInfo->ControlPageID = PageListPtr ? ((UINT16)PageListPtr->PageCount):1; + NewControlInfo->ControlDestPageID = DestPageID; + NewControlInfo->ControlFlags = ControlFlags; + NewControlInfo->ControlHelp = HelpOffset; + NewControlInfo->ControlLabel = (UINT16)controllabel; + NewControlInfo->ControlIndex = (UINT16)controlindex; + NewControlInfo->ControlLabelCount = OpcodeNum; + NewControlInfo->ControlPtr = (VOID*) ControlPtr; + NewControlInfo->ControlConditionalPtr = (VOID*)ConditionalPtr; + NewControlInfo->ControlDataLength = Defaults_size; + NewControlInfo->ControlDataWidth = Defaults_size; + NewControlInfo->QuestionId = QuestionId; + + if(Defaults_size !=0) + { + + switch(Defaults_size) + { + case 1: // BYTE + *((UINT8 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO))) = (UINT8)CtrlFailSafe; + *((UINT8 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO) + Defaults_size)) = (UINT8)CtrlOptimal; + break; + case 2: //WORD + *((UINT16 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO))) = (UINT16)CtrlFailSafe; + *((UINT16 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO) + Defaults_size)) = (UINT16)CtrlOptimal; + break; + case 4: //DWORD + *((UINT32 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO))) = (UINT32)CtrlFailSafe; + *((UINT32 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO) + Defaults_size)) = (UINT32)CtrlOptimal; + break; + } + + } + + ControlOffset = AddControlToList(NewControlInfo, ControlSize); + CreatePage(NewPageInfo, AllocatedPageSize, PageOffset, &ControlOffset, sizeof(UINT32)); + + MemFreePointer(&NewControlInfo); + + if (ControlType & ~ CONTROL_TYPE_MASK) + { + ControlOffset = 0; + CreatePage(NewPageInfo, AllocatedPageSize, PageOffset, &ControlOffset, sizeof(UINT32)); + } + + } + else + AddControl = TRUE; + + switch(ControlType) + { + case CONTROL_TYPE_POPUPSEL: + if( buff[i + sizeof(EFI_IFR_ONE_OF)] == EFI_IFR_ONE_OF_OPTION_OP) + { + j = sizeof(EFI_IFR_ONE_OF); + controlindex+=2; // account for one_of and end_one_of opcodes + while(buff[i+j] == EFI_IFR_ONE_OF_OPTION_OP) + { + j += sizeof(EFI_IFR_ONE_OF_OPTION); + controlindex++; + } + j += sizeof(EFI_IFR_END_ONE_OF); + break; + } + else + { + j= *((char*)buff +i+1); // checkbox + controlindex++; + } + break; + + case CONTROL_TYPE_ORDERED_LIST: + if( buff[i + sizeof(EFI_IFR_ORDERED_LIST)] == EFI_IFR_ONE_OF_OPTION_OP) + { + j = sizeof(EFI_IFR_ONE_OF); + controlindex+=2; // account for one_of and end_one_of opcodes + while(buff[i+j] == EFI_IFR_ONE_OF_OPTION_OP) + { + j += sizeof(EFI_IFR_ONE_OF_OPTION); + controlindex++; + } + j += sizeof(EFI_IFR_END_ONE_OF); + break; + } + + break; + + case CONTROL_TYPE_TIME: + j= 3*(*((char*)buff +i+1)); + controlindex+=2; + break; + + case CONTROL_TYPE_DATE: + j= 3*(*((char*)buff +i+1)); + controlindex+=2; + break; + + case CONTROL_TYPE_VARSTORE: + j= (*((char*)buff +i+1)); + controlindex++; + break; + + default: + if( *((char*)buff +i) != EFI_IFR_LABEL_OP) + controlindex++; + j= *((char*)buff +i+1); + + break; + } + + i= i+ j; + DestPageID = 0x0FFFF; + ControlType = 0; + }; + + return i+2; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiGetEfiKey +// +// Description: Function to Encode the password key +// +// Input: CHAR16 *PwKey +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID HiiGetEfiKey(CHAR16 *PwKey) +{ + EFI_KEY_DESCRIPTOR *pEfiKD = NULL; //, *pRetEfiKD = NULL; + UINT16 Count = 0,i; + EFI_STATUS Status; + + if(EFI_SUCCESS != HiiInitializeProtocol()) + return; + + //Get Count (No Of Key board Desc) + Status= gHiiProtocol->GetKeyboardLayout(gHiiProtocol, &Count, pEfiKD); + + if(EFI_BUFFER_TOO_SMALL != Status) + return; + + if(Count) + { + //Allocate space for Count number of EFI_KEY_DESCRIPTOR + pEfiKD = EfiLibAllocateZeroPool(sizeof(EFI_KEY_DESCRIPTOR)*Count); + + Status= gHiiProtocol->GetKeyboardLayout(gHiiProtocol, &Count, pEfiKD); + + if(EFI_SUCCESS == Status) + { + for(i=0;i<Count;i++) + { + if((pEfiKD[i].Unicode == *PwKey) || + (pEfiKD[i].ShiftedUnicode == *PwKey) || + (pEfiKD[i].AltGrUnicode == *PwKey) || + (pEfiKD[i].ShiftedAltGrUnicode == *PwKey) + ) + { + *PwKey = (CHAR16)(pEfiKD+i)->Key; + break; + } + } + } + MemFreePointer((VOID **)&pEfiKD); + } +} +//---------------------------------------------------------------------------- +// Procedure: _DisplayErrorMessage +// +// Description: Function to display Error message when TSE supported limit exceeds +// +//---------------------------------------------------------------------------- +EFI_STATUS _DisplayErrorMessage(CHAR16 *Temp) +{ + EFI_EVENT Event; + EFI_STATUS status = EFI_SUCCESS;; + status = PostManagerDisplayInfoBox(L" Unrecoverable Error",Temp,20,&Event); + if(status) + { + gST->ConOut->OutputString(gST->ConOut,Temp); + } + return status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiRemoveString +// +// Description: +// +// Parameter: EFI_HII_HANDLE Handle, UINT16 Token +// +// Return value: VOID +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID HiiRemoveString(VOID* Handle, UINT16 Token) +{ + //UEFI2.0 doesn't support +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UefiGetActionWapper +// +// Description: The Wrapper function to get the actual action for the driver +// +// Parameter: UINTN Action +// +// Return Value: EFI_BROWSER_ACTION +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINTN UefiGetActionWapper(UINTN Action) +{ + return Action; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SavePswdString +// +// Description: Dummy fucntion to avoid build error +// +// Parameter: CONTROL_INFO * ControlData, CHAR16 *String +// +// Return Value: VOID +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID SavePswdString (CONTROL_INFO *ControlData, CHAR16 *String) +{ + +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/uefi2.0/hii.h b/EDK/MiniSetup/uefi2.0/hii.h new file mode 100644 index 0000000..d6bd70d --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/hii.h @@ -0,0 +1,328 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.h $ +// +// $Author: Arunsb $ +// +// $Revision: 18 $ +// +// $Date: 4/18/13 9:33a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.h $ +// +// 18 4/18/13 9:33a Arunsb +// Function declarations added to avoid build error in 2.0 +// +// 17 3/25/13 8:34a Premkumara +// [TAG] EIP116315 +// [Category] Improvement +// [Description] Display control prompt string for password control. +// (for String on CHAP secret popup) +// [Files] - AMITSE.sdl +// - CommonHelper.c +// - FakeToken.c +// - AmiTSEStr.uni +// - TseLite\PopupPassword.c +// - uefi2.1\UefiWapper21.c +// - uefi2.0\HiiCallback.c +// - uefi2.0\hii.h +// - uefi2.0\hii.c +// +// 16 10/18/12 6:00a Arunsb +// Updated for 2.16.1235 QA submission +// +// 16 10/10/12 12:39p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 15 11/28/11 5:05a Rajashakerg +// [TAG] EIP73231 +// [Category] Improvement +// [Description] Callback handling :For interactive controls updating +// the currnet vaule in cache even when hii callback returns error status. +// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c, +// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c +// +// 14 11/23/11 5:22a Rajashakerg +// [TAG] EIP75473 +// [Category] Improvement +// [Description] System Time is not updated every second +// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h, +// Uefi21Wapper.c, hii.h, uefi20Wapper.c +// +// 13 3/28/11 5:01p Rajashakerg +// [TAG] EIP56413 +// [Category] Improvement +// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode +// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h, +// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c +// +// 12 3/09/11 7:25p Madhans +// [TAG] EIPEIP48615 +// [Category] Improvement +// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate +// Controls are refershed periodically. +// [Files] minisetupext.h +// SubMenu.h +// SubMenu.c +// Memo.c +// Memo.h +// numeric.c +// numeric.h +// time.c +// Date.c +// PopupSel.c +// PopupSel.h +// PopupString.c +// PopupString.h +// ordlistbox.c +// minisetupext.c +// UefiAction.c +// hii.h +// Uefi20wapper.c +// hiicallback.c +// Parse.c +// tseuefihii.h +// Uefi21wapper.c +// +// 11 2/01/11 7:35p Madhans +// [TAG] - EIP 50737 +// [Category]- Defect +// [Severity]- Mordarate +// [Symptom] - Suppressing the Interactive control does not work +// correctly. +// [RootCause] - The control conditional pointer if not set correctly. +// [Solution]- To fix the Control condition pointer. And identify the +// suppress if related to UEFI action control +// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c +// uefi21wapper.c +// +// 10 12/02/10 6:09p Madhans +// [TAG] - EIP49562 +// [Category]- Improvment. +// [Severity]- Mordarate +// [Symptom]- Need to support UEFI 2.2 requirements related to Calling +// Formcallback with +// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action. +// [Solution]- Implemented the support. +// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c, +// uefi20\hii.h, uefi20\uefi20wrapper.c +// uefi21\hiicalback.c, uefi21\tseuefihii.h +// +// 9 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 8 6/15/10 12:16p Blaines +// Update functon prototype for UefiSetTime and UefiGetTime +// +// 7 6/04/10 12:53p Blaines +// Add support for UEFI 2.1 date and time controls +// +// 6 2/26/10 8:54p Madhans +// For TSE 2.01.1024. refer changelog.log for file checkin history . +// +// 9 2/26/10 1:30p Madhans +// To avoid build issues with EDK. +// +// 8 2/19/10 8:20a Mallikarjunanv +// updated year in copyright message +// +// 7 2/17/10 7:03p Madhans +// +// 6 1/09/10 7:22a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 5 8/17/09 12:28p Presannar +// Removed References to Tiano.h and replace it with Efi.h +// +// 4 7/09/09 12:30p Mallikarjunanv +// updated the password encoding fix +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:08p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:40p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:14p Madhans +// UEFI Wrapper improvments. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: Hii.h +// +// Description: Header file for Hii functionallities +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#ifndef _AMIHII_H_ // DO NOT CHANGE THIS TO _HII_H_ !! That is used by the HII Protocol header +#define _AMIHII_H_ + +#if TSE_USE_EDK_LIBRARY +#include "Tiano.h" +#else +#include "Efi.h" +#endif + +extern /*EFI_HII_HANDLE*/VOID* gHiiHandle; + + +EFI_STATUS HiiExit( VOID ); +EFI_STATUS HiiFixupData( ); +UINTN HiiGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token ); +/*EFI_HII_HANDLE*/VOID* HiiFindHandle( EFI_GUID *guid, UINT16 *index ); +UINT16 HiiAddStringLanguage( /*EFI_HII_HANDLE*/VOID* handle, CHAR16 *lang, CHAR16 *string ); +UINT16 HiiChangeString( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token, CHAR16 *string ); +EFI_STATUS HiiLoadDefaults( VOID **VariableList, UINTN DefaultMask ); +VOID HiiRemoveString(VOID* Handle, UINT16 Token); + +/*EFI_HII_HANDLE*/VOID* * _HiiGetHandles( UINT16 *bufferSize ); +EFI_STATUS _HiiLocateSetupHandles( VOID ); +VOID *_HiiGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *Length ); +UINT16 _HiiGetLinkIndex( EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid ); + +EFI_STATUS _HiiWrapperFindHandles( UINT16 *bufferSize, /*EFI_HII_HANDLE*/VOID* *buffer ); + +#if HII_VERSION <= 1 +EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINT16 *bufferSize, VOID *buffer ); +#else +EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *bufferSize, VOID *buffer ); +#endif +UINTN HiiMyGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token ); +UINTN HiiMyGetMultiLineStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token ); +UINTN IsCharWide( CHAR16 strWide); + + +extern UINTN gTitle; +extern UINTN gHelp; +extern UINTN gSubTitle; +extern UINTN gHelpTitle; +extern UINTN gNavStrings; + +UINT16 UefiGetHelpField(VOID *); +UINT16 UefiGetPromptField(VOID *); +BOOLEAN UefiIsInteractive(CONTROL_INFO *ControlData); +UINT16 UefiGetKeyField(VOID *IfrPtr); +UINT8 UefiGetFlagsField(VOID *IfrPtr); +UINT16 UefiGetControlKey(CONTROL_INFO *ControlData); +UINT16 UefiGetTextField(VOID *IfrPtr); +UINT16 UefiGetTextTwoField(VOID *IfrPtr); +EFI_STATUS CallTextCallBack(TEXT_DATA *text, ACTION_DATA *Data); + +UINT16 UefiGetMessageBoxTitle(VOID *ptr); +UINT16 UefiGetMessageBoxText(VOID *ptr); +VOID* UefiGetMessageBoxHandle(VOID *ptr); +VOID UefiSetSubTitleField(VOID *IfrPtr,UINT16 Token); +VOID * UefiCreateSubTitleTemplate(UINT16 Token); +UINT16 UefiGetTitleField(VOID *IfrPtr); +UINT64 UefiGetMinValue(VOID *IfrPtr); +UINT64 UefiGetMaxValue(VOID *IfrPtr); +UINT16 UefiGetWidth(VOID *IfrPtr); +UINT64 UefiGetStepValue(VOID *IfrPtr); +UINT8 UefiGetBaseValue(VOID *IfrPtr); +UINT16 UefiGetQuestionOffset(VOID *IfrPtr); +EFI_STATUS UefiGetTime(CONTROL_INFO *control, EFI_TIME *Tm); +EFI_STATUS UefiSetTime(CONTROL_INFO *control, EFI_TIME *Tm); +#define AMI_TIME_HOUR 1 +#define AMI_TIME_MIN 2 +#define AMI_TIME_SEC 3 +#define AMI_DATE_YEAR 4 +#define AMI_DATE_MONTH 5 +#define AMI_DATE_DAY 6 +VOID UefiGetDateTimeDetails(VOID *IfrPtr,UINT8 Type,UINT16 * Help,UINT16 * Min,UINT16 * Max); +UINT8 UefiGetIfrLength(VOID *IfrPtr); +VOID UefiSetPromptField(VOID *IfrPtr,UINT16 Token); +EFI_STATUS UefiGetOneOfOptions(CONTROL_INFO *IfrPtr,VOID **Handle,UINT16 **OptionPtrTokens, UINT64 **ValuePtrTokens, UINT16 * ItemCount,UINT16 * Interactive,UINT16 * CallBackKey ); +UINT8 UefiGetMaxEntries(VOID *IfrPtr); +UINT16 UefiTseLiteGetBootOverRideIndex(VOID *Ptr); +UINT16 UefiTseLiteGetAmiCallbackIndex(VOID * Ptr,VOID * Ptr2 ); +EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer); +EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size); + +BOOLEAN UefiIsEfiVariable(UINT32 variable, VARIABLE_INFO *varInfo); +EFI_STATUS UefiVarGetNvram(VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset, UINTN Size); +EFI_STATUS UefiVarSetNvram(VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset, UINTN Size); + +UINTN HiiGetManufactuingMask(VOID); +UINTN HiiGetDefaultMask(VOID); + +VOID* UefiGetSpecialEqIDIfrPtr(CONTROL_INFO *ControlInfo, UINT32 *Variable, GUID_INFO **GuidInfo); +UINT16 UefiGetSpecialEqIDValue(CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo); +VOID UefiSpecialGuidCallback(VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID); +VOID UefiSetEqIDValue(VOID *IfrPtr, UINT16 Value); +BOOLEAN UefiIsOneOfControl(VOID *IfrPtr); +UINT16 UefiGetEqIDQuestionID(VOID *IfrPtr); +VOID UefiSetEqIDQuestionID(VOID *IfrPtr, UINT16 Value); +VOID* UefiCreateOneOfWithOptionsTemplate(UINTN OptionCount, CONTROL_INFO *CtrlInfo); +VOID UefiSetOneOfOption(VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option); +UINT32 GetControlConditionVarId(CONTROL_INFO *control); +VOID UefiUpdateControlVarOffset(VOID *IfrPtr, UINT16 Value); +VOID UefiSetWidth(VOID *IfrPtr,UINT8 Width); +VOID UefiAddEndOp(VOID *IfrPtr); +VOID BBSUpdateControlOffset(CONTROL_INFO *control); +UINT16 UefiGetQuestionID(CONTROL_INFO *control); +VOID UefiCreateDynamicControlCondition(CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value); +EFI_STATUS SpecialActionCallBack(CONTROL_INFO * ControlData, UINT16 Key); +EFI_STATUS ProcessActionQuestionConfiguration(CONTROL_INFO *control); +//EIP 23354 : Start +BOOLEAN IsPasswordEncodeEnabled(VOID *PwDataPtr); +//EIP 23354 : End +EFI_STATUS UefiIsProceedWithPageChange(EFI_STATUS Status); +VOID UefiPreControlUpdate(CONTROL_INFO *ControlData); +EFI_STATUS UefiRefershQuestionValueNvRAM(CONTROL_INFO *ControlData); +UINT16 UefiGetResetButtonDefaultid(VOID *IfrPtr);//EIP:56413 Function decleration to get the Default ID +//EIP:56413 Function to update the Resetbutton Defaults to the control +EFI_STATUS UefiupdateResetButtonDefault(CONTROL_INFO ControlData, UINT16 DefaultId); +BOOLEAN CheckTimeFlags(UINT8 Flags); +BOOLEAN CheckDateFlags(UINT8 Flags); +UINTN UefiGetActionWapper(UINTN Action); +VOID UefiGetValidOptionType(CONTROL_INFO *CtrlInfo, UINTN *Type, UINT32 *SizeOfData); +#endif /* _AMIHII_H_ */ + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/uefi2.0/uefi20.mak b/EDK/MiniSetup/uefi2.0/uefi20.mak new file mode 100644 index 0000000..cc33631 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/uefi20.mak @@ -0,0 +1,128 @@ +##*****************************************************************## +##*****************************************************************## +##*****************************************************************## +##** **## +##** (C)Copyright 2010, American Megatrends, Inc. **## +##** **## +##** All Rights Reserved. **## +##** **## +##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **## +##** **## +##** Phone (770)-246-8600 **## +##** **## +##*****************************************************************## +##*****************************************************************## +##*****************************************************************## +## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20.mak $ +## +## $Author: Arunsb $ +## +## $Revision: 8 $ +## +## $Date: 10/18/12 6:00a $ +## +##*****************************************************************## +##*****************************************************************## +## Revision History +## ---------------- +## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20.mak $ +# +# 8 10/18/12 6:00a Arunsb +# Updated for 2.16.1235 QA submission +## +## 9 10/10/12 12:39p Arunsb +## Synched the source for v2.16.1232, backup with Aptio +# +# 7 4/23/10 6:12p Madhans +# +# 6 2/19/10 1:04p Madhans +# Updated for TSE 2.01. Refer Changelog.log for File change history. +## +## 6 2/19/10 8:20a Mallikarjunanv +## updated year in copyright message +## +## 5 10/28/09 5:38p Madhans +## +## 4 8/17/09 12:28p Presannar +## Removed Include Path to Core Dir +## +## 3 6/24/09 6:11p Madhans +## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +## +## 2 6/12/09 7:44p Presannar +## Initial implementation of coding standards for AMITSE2.0 +## +## 1 6/04/09 8:05p Madhans +# +# 1 4/28/09 11:09p Madhans +# Tse 2.0 Code complete Checkin. +## +## 3 4/28/09 9:40p Madhans +## Tse 2.0 Code complete Checkin. +## +## 2 2/05/09 10:15a Madhans +## Style Module created. +## +## 1 12/18/08 7:59p Madhans +## Intial version of TSE Lite sources +## +## +##*****************************************************************## +##*****************************************************************## + +# MAK file for the eModule:TseLite + +UEFI20_INCLUDES = \ + -I $(TSESRC_DIR) \ +!if "$(TSE_STYLE_SOURCES_SUPPORT)" == "1" + -I $(TSE_STYLE_DIR) \ +!endif +!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1" + -I $(TSE_BOARD_DIR)\ +!endif + -I $(TSESRC_DIR)\AMILOGO \ + -I $(TSELITESRC_DIR) \ + -I $(UEFISRC_DIR) \ + -I $(TSEBIN_DIR) \ + -I $(TSEBIN_DIR)\Inc \ + -I $(PROJECT_DIR)\Include\Protocol \ + -I $(PROJECT_DIR) \ + -I $(PROJECT_DIR)\Include \ + -I $(BUILD_DIR) \ + +$(BUILD_DIR)\Uefi20Local.lib : Uefi20Lib + +Uefi20Lib : $(BUILD_DIR)\Uefi20.mak Uefi20LibBin + +$(BUILD_DIR)\Uefi20.mak : $(UEFISRC_DIR)\$(@B).cif $(UEFISRC_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(UEFISRC_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +!if "$(TSE_USE_EDK_LIBRARY)" == "1" +TSE_DEFAULTS = $(EDK_DEFAULTS) +!else +TSE_DEFAULTS = $(BUILD_DEFAULTS) +!endif + +Uefi20LibBin : + $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\ + /f $(BUILD_DIR)\Uefi20.mak all\ + "MY_INCLUDES=$(UEFI20_INCLUDES)"\ + "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\ + TYPE=LIBRARY \ + "EXT_HEADERS=$(BUILD_DIR)\token.h"\ + LIBRARY_NAME=$(BUILD_DIR)\Uefi20Local.lib\ + "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50" + +##*****************************************************************## +##*****************************************************************## +##** **## +##** (C)Copyright 2010, American Megatrends, Inc. **## +##** **## +##** All Rights Reserved. **## +##** **## +##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **## +##** **## +##** Phone (770)-246-8600 **## +##** **## +##*****************************************************************## +##*****************************************************************## diff --git a/EDK/MiniSetup/uefi2.0/uefi20.sdl b/EDK/MiniSetup/uefi2.0/uefi20.sdl new file mode 100644 index 0000000..95cdca4 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/uefi20.sdl @@ -0,0 +1,53 @@ +TOKEN + Name = "UEFI_2_0_SUPPORT" + Value = "1" + Help = "Main switch to enable UEFI 2.0 sources support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes + Token = "EFI_SPECIFICATION_VERSION" "<=" "0x20000" +End + +TOKEN + Name = "UEFI_SOURCES_SUPPORT" + Value = "1" + Help = "Don't Edit." + TokenType = Boolean + TargetH = Yes + TargetMAK = Yes +End + +TOKEN + Name = "TSE_SUPPORT_VFRCOMPILE_1_88" + Value = "1" + Help = "Turn on to support vfrcompiler version 1.88 and later" + TokenType = Boolean + TargetH = Yes +End + +TOKEN + Name = "SETUP_FORM_BROWSER_SUPPORT" + Value = "0" + Help = "1 => Installs form browser protocol should turn on SETUP_RUNTIME_IFR_PROCESSING. 0 => Does not install form browser protocol." + TokenType = Boolean + TargetH = Yes + Token = "SETUP_RUNTIME_IFR_PROCESSING" "=" "1" + Token = "TSE_USE_EDK_LIBRARY" "=" "1" +End + +PATH + Name = "UEFISRC_DIR" +End + +MODULE + Help = "Includes Uefi20.mak to Project" + File = "Uefi20.mak" +End + +ELINK + Name = "$(BUILD_DIR)\Uefi20Local.lib" + Parent = "$(UEFISRC_DIR)\Uefi20Local$(ARCH).lib" + InvokeOrder = ReplaceParent +End + diff --git a/EDK/MiniSetup/uefi2.0/uefi20Wapper.c b/EDK/MiniSetup/uefi2.0/uefi20Wapper.c new file mode 100644 index 0000000..8b4bf06 --- /dev/null +++ b/EDK/MiniSetup/uefi2.0/uefi20Wapper.c @@ -0,0 +1,2428 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20Wapper.c $ +// +// $Author: Arunsb $ +// +// $Revision: 34 $ +// +// $Date: 5/02/14 10:38p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20Wapper.c $ +// +// 34 5/02/14 10:38p Arunsb +// gEnableProcessPack variable added to avoid build error +// +// 33 6/10/13 2:15p Arunsb +// EvaluateControlDefault function added to avoid build error in 2.0 +// +// 32 3/25/13 8:34a Premkumara +// [TAG] EIP116315 +// [Category] Improvement +// [Description] Display control prompt string for password control. +// (for String on CHAP secret popup) +// [Files] - AMITSE.sdl +// - CommonHelper.c +// - FakeToken.c +// - AmiTSEStr.uni +// - TseLite\PopupPassword.c +// - uefi2.1\UefiWapper21.c +// - uefi2.0\HiiCallback.c +// - uefi2.0\hii.h +// - uefi2.0\hii.c +// +// 31 10/18/12 6:00a Arunsb +// Updated for 2.16.1235 QA submission +// +// 18 10/10/12 12:39p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 28 9/25/12 1:45p Premkumara +// EIP - 99059 - Updated for UEFI2.0 +// Files - Hii.c, Uefi20Wapper.c +// +// 27 2/02/12 2:56a Premkumara +// [TAG] EIP75066 +// [Category] Improvement +// [Description] Support loading defaults for Ordelist controls +// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c, +// Parse.c, Uefi20Wapper.c, TseUefihiil.h +// +// 26 12/08/11 9:37a Rajashakerg +// [TAG] EIP75588 +// [Category] Improvement +// [Description] Updated the file to aviod build errors when build for +// UEFI 20 by providing the dummy functions. +// +// 25 12/02/11 1:52a Premkumara +// [TAG] EIP73226 +// [Category] New Feature +// [Description] Extended support for password prompt +// [Files] FakeToken.c, Uefi21Wapper.c, AmiTSEStr.uni, PopupPassword.c, +// HiiCallBack.c, Uefi20Wapper.c +// +// 24 12/01/11 7:16p Blaines +// Fix build errors in Uefi2.0 +// +// 23 11/28/11 5:06a Rajashakerg +// [TAG] EIP73231 +// [Category] Improvement +// [Description] Callback handling :For interactive controls updating +// the currnet vaule in cache even when hii callback returns error status. +// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c, +// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c +// +// 22 11/23/11 5:24a Rajashakerg +// [TAG] EIP75473 +// [Category] Improvement +// [Description] System Time is not updated every second +// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h, +// Uefi21Wapper.c, hii.h, uefi20Wapper.c +// +// 21 10/18/11 1:50p Blaines +// [TAG] - EIP 66860 +// [Category]- Function Request +// [Synopsis]- AmiPostManager interface for text entry. +// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h, +// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c, +// uefi20Wapper.c +// +// 20 6/30/11 4:15a Arunsb +// [TAG] EIP57661 +// [Category] New Feature +// [Description] Boot manager algorithm for interaction with Driver +// Health protocol. +// Wrapper functions added. +// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni, +// commonhelper.c, uefisetup.ini, tsedrvhealth.h, +// amivfr.h, minisetupbin.mak, +// hiistring21.c, hiistring20.c, tseadvanced.c, special.c, +// special.h, boot.h, minisetup.h, +// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and +// uefi21wapper.c. +// +// 19 6/28/11 3:44p Arunsb +// [TAG] EIP55762 +// [Description] Dummy UpdateDestiantionQuestion function added +// +// 18 4/29/11 4:39p Arunsb +// For 2.13 public patch release IFR RefX feature is omitted +// +// 16 3/28/11 5:03p Rajashakerg +// [TAG] EIP56413 +// [Category] Improvement +// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode +// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h, +// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c +// +// 15 3/09/11 7:25p Madhans +// [TAG] EIPEIP48615 +// [Category] Improvement +// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate +// Controls are refershed periodically. +// [Files] minisetupext.h +// SubMenu.h +// SubMenu.c +// Memo.c +// Memo.h +// numeric.c +// numeric.h +// time.c +// Date.c +// PopupSel.c +// PopupSel.h +// PopupString.c +// PopupString.h +// ordlistbox.c +// minisetupext.c +// UefiAction.c +// hii.h +// Uefi20wapper.c +// hiicallback.c +// Parse.c +// tseuefihii.h +// Uefi21wapper.c +// +// 14 2/01/11 7:41p Madhans +// [TAG] - EIP 52032 +// [Category]- Defect +// [Severity]- Mordarate +// [Symptom] - In UEFI2.0 Updating the Interactive One of Control may not +// work correctly. +// [RootCause] - The UefiGetControlKey for Interactive one of control is +// not returned properly. +// [Solution]- fix in UefiGetControlKey control. +// [Files] - uefi20wapper.c +// +// 13 2/01/11 7:37p Madhans +// [TAG] - EIP 50737 +// [Category]- Defect +// [Severity]- Mordarate +// [Symptom] - Suppressing the Interactive control does not work +// correctly. +// [RootCause] - The control conditional pointer if not set correctly. +// [Solution]- To fix the Control condition pointer. And identify the +// suppress if related to UEFI action control +// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c +// uefi21wapper.c +// +// 12 12/02/10 6:09p Madhans +// [TAG] - EIP49562 +// [Category]- Improvment. +// [Severity]- Mordarate +// [Symptom]- Need to support UEFI 2.2 requirements related to Calling +// Formcallback with +// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action. +// [Solution]- Implemented the support. +// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c, +// uefi20\hii.h, uefi20\uefi20wrapper.c +// uefi21\hiicalback.c, uefi21\tseuefihii.h +// +// 11 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 10 6/15/10 12:16p Blaines +// Update functon prototype for UefiSetTime and UefiGetTime +// +// 9 6/04/10 12:53p Blaines +// Add support for UEFI 2.1 date and time controls +// +// 8 2/19/10 1:04p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 11 2/19/10 8:20a Mallikarjunanv +// updated year in copyright message +// +// 10 1/29/10 4:34p Madhans +// To avoid compiler warnings. +// +// 9 1/27/10 12:59p Madhans +// // EIP 33804 : Issue iSCSI initiator name is not saved.. +// +// 8 1/09/10 7:30a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 7 10/19/09 10:52a Blaines +// EIP #26029 Fix: UefiCreateOneOfWithOptionsTemplate() does not always +// return NULL when EfiLibAllocateZeroPool() returns NULL +// +// 6 7/09/09 12:30p Mallikarjunanv +// updated the password encoding fix +// +// 4 6/24/09 6:11p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:51p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:09p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:40p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:14p Madhans +// UEFI Wrapper improvments. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +// +// +//*****************************************************************// +//*****************************************************************// + +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: uefi20wraper.c +// +// Description: This file contains code for UEFI2.0 wrapper +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "minisetup.h" +#include EFI_PROTOCOL_DEFINITION(Hii) +#include EFI_PROTOCOL_DEFINITION(FormCallback) +extern EFI_HII_PROTOCOL *gHiiProtocol; +BOOLEAN gPackUpdatePending = FALSE; +BOOLEAN gEnableProcessPack = FALSE; //Added to avoid build error + +static EFI_IFR_SUBTITLE _Title = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 }; +static EFI_IFR_SUBTITLE _Help = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 }; +static EFI_IFR_SUBTITLE _SubTitle = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 }; +static EFI_IFR_SUBTITLE _HelpTitle = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, STRING_TOKEN(STR_HELP_TITLE) }; +static EFI_IFR_SUBTITLE _NavStrings = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 }; + +UINTN gTitle = (UINTN)&_Title; +UINTN gHelp = (UINTN)&_Help; +UINTN gSubTitle = (UINTN)&_SubTitle; +UINTN gHelpTitle = (UINTN)&_HelpTitle; +UINTN gNavStrings = (UINTN)&_NavStrings; + +EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle ); +EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index ); +VOID *UefiCreateStringTemplate(UINT16 Token); + +UINT32 FindVarFromITKQuestionId(UINT16 QuestionId); +UINT32 GetVarNumFromVarID(UINT32 ID); +VOID UefiSetHelpField(VOID *IfrPtr,UINT16 Token); +////For avoiding build error EIP101564 +UINT32 gRefreshIdCount = 0; //No. of controls with Refresh Id set +REFRESH_ID_INFO *gRefreshIdInfo = NULL; + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetHelpField +// +// Description: To get the specific help field +// +// Input: VOID *IfrPtr +// +// Output: Help Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetHelpField(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_REF_OP: + return ((EFI_IFR_REF*)OpHeader)->Help; + break; + case EFI_IFR_TEXT_OP: + return ((EFI_IFR_TEXT*)OpHeader)->Help; + break; + case EFI_IFR_ONE_OF_OP: + return ((EFI_IFR_ONE_OF*)OpHeader)->Help; + break; + case EFI_IFR_TIME_OP: + case EFI_IFR_DATE_OP: + case EFI_IFR_NUMERIC_OP: + return ((EFI_IFR_NUMERIC*)OpHeader)->Help; + break; + case EFI_IFR_PASSWORD_OP: + return ((EFI_IFR_PASSWORD*)OpHeader)->Help; + break; + case EFI_IFR_STRING_OP: + return ((EFI_IFR_STRING*)OpHeader)->Help; + break; + default: + break; + } + + return 0; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetHelpField +// +// Description: To Set the specific help field +// +// Input: VOID *IfrPtr, UINT16 Token +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSetHelpField(VOID *IfrPtr, UINT16 Token) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_REF_OP: + ((EFI_IFR_REF*)OpHeader)->Help = Token ; + break; + case EFI_IFR_TEXT_OP: + ((EFI_IFR_TEXT*)OpHeader)->Help = Token ; + break; + case EFI_IFR_ONE_OF_OP: + ((EFI_IFR_ONE_OF*)OpHeader)->Help = Token ; + break; + case EFI_IFR_TIME_OP: + case EFI_IFR_DATE_OP: + case EFI_IFR_NUMERIC_OP: + ((EFI_IFR_NUMERIC*)OpHeader)->Help = Token ; + break; + case EFI_IFR_PASSWORD_OP: + ((EFI_IFR_PASSWORD*)OpHeader)->Help = Token ; + break; + case EFI_IFR_STRING_OP: + ((EFI_IFR_STRING*)OpHeader)->Help = Token ; + break; + default: + break; + } +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetPromptField +// +// Description: To get the prompt field from ifr +// +// Input: VOID *IfrPtr +// +// Output: Prompt Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetPromptField(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_REF_OP: + return ((EFI_IFR_REF*)OpHeader)->Prompt; + break; + case EFI_IFR_NUMERIC_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_DATE_OP: + return ((EFI_IFR_NUMERIC*)OpHeader)->Prompt; + break; + case EFI_IFR_ONE_OF_OP: + return ((EFI_IFR_ONE_OF*)OpHeader)->Prompt; + break; + case EFI_IFR_ORDERED_LIST_OP: + return ((EFI_IFR_ORDERED_LIST*)OpHeader)->Prompt; + break; + case EFI_IFR_CHECKBOX_OP: + return ((EFI_IFR_CHECK_BOX*)OpHeader)->Prompt; + break; + case EFI_IFR_PASSWORD_OP: + return ((EFI_IFR_PASSWORD*)OpHeader)->Prompt; + break; + case EFI_IFR_STRING_OP: + return ((EFI_IFR_STRING*)OpHeader)->Prompt; + break; + default: + break; + } + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetKeyField +// +// Description: To get the Key field from ifr +// +// Input: VOID *IfrPtr +// +// Output: Key Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetKeyField(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_REF_OP: + return ((EFI_IFR_REF*)OpHeader)->Key; + break; + case EFI_IFR_NUMERIC_OP: + return ((EFI_IFR_NUMERIC*)OpHeader)->Key; + break; + case EFI_IFR_PASSWORD_OP: + return ((EFI_IFR_PASSWORD*)OpHeader)->Key; + break; + case EFI_IFR_TEXT_OP: + return ((EFI_IFR_TEXT*)OpHeader)->Key; + break; + case EFI_IFR_CHECKBOX_OP: + return ((EFI_IFR_CHECK_BOX*)OpHeader)->Key; + break; + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_ORDERED_LIST_OP: + if(OpHeader->OpCode == EFI_IFR_ORDERED_LIST_OP) + OpHeader = (EFI_IFR_OP_HEADER *)(((UINT8 *)OpHeader) +sizeof(EFI_IFR_ORDERED_LIST) ); + else + OpHeader = (EFI_IFR_OP_HEADER *)(((UINT8 *)OpHeader) +sizeof(EFI_IFR_ONE_OF) ); + return ((EFI_IFR_ONE_OF_OPTION*)OpHeader)->Key; + break; + case EFI_IFR_ONE_OF_OPTION_OP: + return ((EFI_IFR_ONE_OF_OPTION*)OpHeader)->Key; + break; + case EFI_IFR_STRING_OP: + return ((EFI_IFR_STRING*)OpHeader)->Key; + break; + default: + break; + } + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetTitleField +// +// Description: To get the Title field from ifr +// +// Input: VOID *IfrPtr +// +// Output: Title Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetTitleField(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_SUBTITLE_OP: + return ((EFI_IFR_SUBTITLE*)OpHeader)->SubTitle; + break; + case EFI_IFR_FORM_OP: + return ((EFI_IFR_FORM*)OpHeader)->FormTitle; + break; + default: + break; + } + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetFlagsField +// +// Description: to get the Flags field from ifr +// +// Input: VOID *IfrPtr +// +// Output: Flags Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 UefiGetFlagsField(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_REF_OP: + return ((EFI_IFR_REF*)OpHeader)->Flags; + break; + default: + break; + } + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiIsInteractive +// +// Description: To get Uefi Interactive +// +// Input: CONTROL_INFO *ControlData +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN UefiIsInteractive(CONTROL_INFO *ControlData) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)ControlData->ControlPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_REF_OP: + return ((((EFI_IFR_REF*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE); + break; + case EFI_IFR_NUMERIC_OP: + return ((((EFI_IFR_NUMERIC*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE); + break; + case EFI_IFR_STRING_OP: + return ((((EFI_IFR_STRING*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE); + break; + case EFI_IFR_PASSWORD_OP: + return ((((EFI_IFR_PASSWORD*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE); + break; + default: + break; + } + + return FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetControlKey +// +// Description: Helper function in obtaining Control Key +// +// Input: CONTROL_INFO *ControlData +// +// Output: Key Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetControlKey(CONTROL_INFO *ControlData) +{ + return UefiGetKeyField((VOID*)ControlData->ControlPtr); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetTextField +// +// Description: Function to get the Text Field. +// +// Input: VOID *IfrPtr +// +// Output: Text Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetTextField(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_TEXT_OP: + return ((EFI_IFR_TEXT*)OpHeader)->Text; + break; + default: + break; + } + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetTextTwoField +// +// Description: Function to get the Text Field. +// +// Input: VOID *IfrPtr +// +// Output: Text Field +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetTextTwoField(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_TEXT_OP: + return ((EFI_IFR_TEXT*)OpHeader)->TextTwo; + break; + default: + break; + } + + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetSubTitleField +// +// Description: Function to Set the Sub-Title Field. +// +// Input: VOID *IfrPtr, UINT16 Token +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSetSubTitleField(VOID *IfrPtr,UINT16 Token) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_SUBTITLE_OP: + ((EFI_IFR_SUBTITLE*)OpHeader)->SubTitle = Token; + break; + default: + break; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetPromptField +// +// Description: Function to set the prompt Field. +// +// Input: VOID *IfrPtr, UINT16 Token +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSetPromptField(VOID *IfrPtr,UINT16 Token) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_REF_OP: + ((EFI_IFR_REF*)OpHeader)->Prompt = Token; + break; + case EFI_IFR_NUMERIC_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_DATE_OP: + ((EFI_IFR_NUMERIC*)OpHeader)->Prompt = Token; + break; + case EFI_IFR_ONE_OF_OP: + ((EFI_IFR_ONE_OF*)OpHeader)->Prompt = Token; + break; + case EFI_IFR_ORDERED_LIST_OP: + ((EFI_IFR_ORDERED_LIST*)OpHeader)->Prompt = Token; + break; + case EFI_IFR_CHECKBOX_OP: + ((EFI_IFR_CHECK_BOX*)OpHeader)->Prompt = Token; + break; + case EFI_IFR_PASSWORD_OP: + ((EFI_IFR_PASSWORD*)OpHeader)->Prompt = Token; + break; + case EFI_IFR_STRING_OP: + ((EFI_IFR_STRING*)OpHeader)->Prompt = Token; + break; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiCreateSubTitleTemplate +// +// Description: Function to prepare the template for sub-title +// +// Input: UINT16 Token +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID * UefiCreateSubTitleTemplate(UINT16 Token) +{ + EFI_IFR_OP_HEADER *OpHeader = EfiLibAllocateZeroPool(sizeof(EFI_IFR_SUBTITLE)); + + OpHeader->OpCode = EFI_IFR_SUBTITLE_OP ; + OpHeader->Length = sizeof(EFI_IFR_SUBTITLE) ; + UefiSetSubTitleField((VOID *)OpHeader,Token); + return (VOID*)OpHeader; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetIfrLength +// +// Description: Function to get the length of Ifr +// +// Input: VOID *IfrPtr +// +// Output: Length +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 UefiGetIfrLength(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + return OpHeader->Length; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetMinValue +// +// Description: Function to get the minimum value +// +// Input: VOID *IfrPtr +// +// Output: UINT64 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT64 UefiGetMinValue(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_NUMERIC_OP: + return (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->Minimum; + break; + case EFI_IFR_PASSWORD_OP: + return (UINT64)((EFI_IFR_PASSWORD*)OpHeader)->MinSize; + break; + case EFI_IFR_STRING_OP: + return (UINT64)((EFI_IFR_STRING*)OpHeader)->MinSize; + break; + default: + break; + } + return (UINT64)0; + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetMaxValue +// +// Description: Function to get the max value +// +// Input: VOID *IfrPtr +// +// Output: UINT64 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT64 UefiGetMaxValue(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_NUMERIC_OP: + return (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->Maximum; + break; + case EFI_IFR_PASSWORD_OP: + return (UINT64)((EFI_IFR_PASSWORD*)OpHeader)->MaxSize; + break; + case EFI_IFR_STRING_OP: + return (UINT64)((EFI_IFR_STRING*)OpHeader)->MaxSize; + break; + default: + break; + } + return (UINT64)0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetStepValue +// +// Description: Function to get the step value +// +// Input: VOID *IfrPtr +// +// Output: UINT64 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT64 UefiGetStepValue(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_NUMERIC_OP: + return (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->Step; + break; + default: + break; + } + return (UINT64)0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetBaseValue +// +// Description: Function to get the base value +// +// Input: VOID *IfrPtr +// +// Output: UINT8 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 UefiGetBaseValue(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_NUMERIC_OP: + return AMI_BASE_DEC; + break; + default: + break; + } + return AMI_BASE_DEC; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetWidth +// +// Description: Function to get width +// +// Input: VOID *IfrPtr +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetWidth(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_NUMERIC_OP: + return (UINT16)((EFI_IFR_NUMERIC*)OpHeader)->Width; + break; + case EFI_IFR_PASSWORD_OP: + return (UINT16)((EFI_IFR_PASSWORD*)OpHeader)->Width; + break; + case EFI_IFR_STRING_OP: + return (UINT16)((EFI_IFR_STRING*)OpHeader)->Width; + break; + case EFI_IFR_ONE_OF_OP: + return (UINT16)((EFI_IFR_ONE_OF*)OpHeader)->Width; + break; + case EFI_IFR_CHECKBOX_OP: + return (UINT16)((EFI_IFR_CHECK_BOX*)OpHeader)->Width; + break; + case EFI_IFR_EQ_ID_VAL_OP: + return (UINT16)((EFI_IFR_EQ_ID_VAL*)OpHeader)->Width; + break; + case EFI_IFR_EQ_ID_LIST_OP: + return (UINT16)((EFI_IFR_EQ_ID_LIST*)OpHeader)->Width; + break; + case EFI_IFR_EQ_ID_ID_OP: + return (UINT16)((EFI_IFR_EQ_ID_ID*)OpHeader)->Width; + break; + default: + break; + } + return (UINT16)0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetWidth +// +// Description: Function to set width +// +// Input: VOID *IfrPtr +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSetWidth(VOID *IfrPtr,UINT8 Width) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_NUMERIC_OP: + ((EFI_IFR_NUMERIC*)OpHeader)->Width = Width; + break; + case EFI_IFR_PASSWORD_OP: + ((EFI_IFR_PASSWORD*)OpHeader)->Width = Width ; + break; + case EFI_IFR_STRING_OP: + ((EFI_IFR_STRING*)OpHeader)->Width = Width; + break; + case EFI_IFR_ONE_OF_OP: + ((EFI_IFR_ONE_OF*)OpHeader)->Width = Width; + break; + case EFI_IFR_CHECKBOX_OP: + ((EFI_IFR_CHECK_BOX*)OpHeader)->Width = Width; + break; + case EFI_IFR_EQ_ID_VAL_OP: + ((EFI_IFR_EQ_ID_VAL*)OpHeader)->Width = Width; + break; + case EFI_IFR_EQ_ID_LIST_OP: + ((EFI_IFR_EQ_ID_LIST*)OpHeader)->Width = Width; + break; + case EFI_IFR_EQ_ID_ID_OP: + ((EFI_IFR_EQ_ID_ID*)OpHeader)->Width = Width; + break; + default: + break; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetQuestionOffset +// +// Description: Function to get question offset +// +// Input: VOID *IfrPtr +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetQuestionOffset(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + return (UINT16)((EFI_IFR_NV_DATA*)OpHeader)->QuestionId; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetDateTimeDetails +// +// Description: Function to get the details of data and time +// +// Input: VOID *IfrPtr, +// UINT8 Type, +// UINT16 * Help, +// UINT16 * Min, +// UINT16 * Max +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiGetDateTimeDetails(VOID *IfrPtr,UINT8 Type,UINT16 * Help,UINT16 * Min,UINT16 * Max) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + EFI_IFR_NUMERIC *NumIfr=NULL; + switch(OpHeader->OpCode) + { + case EFI_IFR_TIME_OP: + if(Type == AMI_TIME_HOUR) + NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Hour); + else if (Type == AMI_TIME_MIN) + NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Minute); + else if (Type == AMI_TIME_SEC) + NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Second); + break; + case EFI_IFR_DATE_OP: + if(Type == AMI_DATE_YEAR) + NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Year); + else if (Type == AMI_DATE_MONTH) + NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Month); + else if (Type == AMI_DATE_DAY) + NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Day); + break; + default: + break; + } + if(NumIfr) + { + *Help = NumIfr->Help; + *Min = NumIfr->Minimum; + *Max = NumIfr->Maximum; + } + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetOneOfOptions +// +// Description: Function to get OneOf options +// +// Input: VOID *IfrPtr, +// VOID **Handle, +// UINT16 **OptionPtrTokens, +// UINT64 **ValuePtrTokens, +// UINT16 * ItemCount, +// UINT16 * Interactive, +// UINT16 * CallBackKey +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiGetOneOfOptions(CONTROL_INFO *CtrlInfo,VOID **Handle,UINT16 **OptionPtrTokens, UINT64 **ValuePtrTokens, UINT16 * ItemCount,UINT16 * Interactive,UINT16 * CallBackKey ) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)(CtrlInfo->ControlPtr); + EFI_IFR_ONE_OF_OPTION *ptrData; + UINT8 Opcode = OpHeader->OpCode; + EFI_STATUS Status = EFI_SUCCESS; + UINT16 Index= 0 ; + + if(Opcode == EFI_IFR_ORDERED_LIST_OP) + ptrData = (EFI_IFR_ONE_OF_OPTION *)((UINT8 *)(OpHeader) +sizeof(EFI_IFR_ORDERED_LIST) ); + else + ptrData = (EFI_IFR_ONE_OF_OPTION *)((UINT8 *)(OpHeader) +sizeof(EFI_IFR_ONE_OF) ); + + switch ( Opcode ) + { + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_ORDERED_LIST_OP: // ordered list option + while( ptrData[Index].Header.OpCode != EFI_IFR_END_ONE_OF_OP ) + Index++; + break; + + case EFI_IFR_CHECKBOX_OP: + Index = 2; + *Handle = gHiiHandle; + break; + } + if( *OptionPtrTokens != NULL ) + MemFreePointer( (VOID **)OptionPtrTokens); + + if(ValuePtrTokens) + if( *ValuePtrTokens != NULL ) + MemFreePointer( (VOID **)ValuePtrTokens); + + + *OptionPtrTokens = EfiLibAllocatePool( Index * sizeof(UINT16) ); + + if(ValuePtrTokens) + *ValuePtrTokens = EfiLibAllocatePool( Index * sizeof(UINT64) ); + + if ( *OptionPtrTokens == NULL ) + Status = EFI_OUT_OF_RESOURCES; + else + { + *ItemCount = Index; + + for ( Index = 0; Index < *ItemCount; Index++ ) + { + if( ((Opcode == EFI_IFR_ONE_OF_OP)|(Opcode == EFI_IFR_ORDERED_LIST_OP)) && (ptrData->Header.OpCode == EFI_IFR_ONE_OF_OPTION_OP) ) + { + (*OptionPtrTokens)[Index] = ptrData[Index].Option; + if(ValuePtrTokens) + (*ValuePtrTokens)[Index] = ptrData[Index].Value; + + if(ptrData[Index].Flags & EFI_IFR_FLAG_INTERACTIVE) + { + if(Interactive) *Interactive = TRUE; + if(CallBackKey) *CallBackKey = ptrData[Index].Key; + } + } + else + { + (*OptionPtrTokens)[Index] = gCheckboxTokens[Index]; + if(ValuePtrTokens) + (*ValuePtrTokens)[Index] = Index; + if(((EFI_IFR_CHECK_BOX *)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE) + { + if(Interactive) *Interactive = TRUE; + if(CallBackKey) *CallBackKey = ((EFI_IFR_CHECK_BOX *)OpHeader)->Key; + } + + } + } + } + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetMaxEntries +// +// Description: Function to get max entries +// +// Input: VOID *IfrPtr, +// +// Output: UINT8 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 UefiGetMaxEntries(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr; + + switch(OpHeader->OpCode) + { + case EFI_IFR_ORDERED_LIST_OP: + return ((EFI_IFR_ORDERED_LIST*)OpHeader)->MaxEntries; + break; + default: + break; + } + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiTseLiteGetBootOverRideIndex +// +// Description: Function to get boot override index +// +// Input: VOID *Ptr, +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiTseLiteGetBootOverRideIndex(VOID *Ptr) +{ + UINT16 Index=0xFFFF; + EFI_IFR_OP_HEADER * OpHeader = (EFI_IFR_OP_HEADER *)Ptr; + EFI_IFR_EQ_ID_LIST *EqIdList; + + if ((OpHeader != NULL) && (OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP)) + { + while(OpHeader->OpCode != EFI_IFR_EQ_ID_LIST_OP) + { + OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length); + if(OpHeader->OpCode == EFI_IFR_END_IF_OP) // Not found + return Index; + } + + // FIX ME : Do it better. Check the list length and + if(OpHeader->OpCode == EFI_IFR_EQ_ID_LIST_OP) + { + EqIdList = (EFI_IFR_EQ_ID_LIST*)OpHeader; + Index = EqIdList->ListLength - 1; + } + } + + return Index; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiTseLiteGetAmiCallbackIndex +// +// Description: Function to get ami callback index +// +// Input: VOID *Ptr, +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiTseLiteGetAmiCallbackIndex(VOID * Ptr, VOID * Ptr2) +{ + UINT16 Index=0xFFFF; + EFI_IFR_OP_HEADER * OpHeader = (EFI_IFR_OP_HEADER *)Ptr; + + if ((OpHeader != NULL) && (OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP)) + { + while(OpHeader->OpCode != EFI_IFR_EQ_ID_VAL_OP) + { + OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length); + if(OpHeader->OpCode == EFI_IFR_END_IF_OP) // Not found + return Index; + } + + // FIX ME : Do it better. Check the list length and + if(OpHeader->OpCode == EFI_IFR_EQ_ID_VAL_OP) + { + Index = ((EFI_IFR_EQ_ID_VAL*)OpHeader)->Value; + } + } + + return Index; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiFormCallbackNVRead +// +// Description: Function to get callback nvread +// +// Input: CHAR16 *name, +// EFI_GUID *guid, +// UINT32 *attributes, +// UINTN *size, +// VOID **buffer +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer) +{ + EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL; + EFI_STATUS Status = EFI_UNSUPPORTED; + EFI_IFR_FORM_SET *FmSet=NULL; + UINTN i=0; + + if(gSetupCount) + { + for ( i = 0; i < gSetupCount - 1; i++ ) + { + FmSet = HiiGetFormSet( i ); + if(!FmSet) + continue; + + if( EfiCompareGuid(&(FmSet->Guid),guid) && (EFI_HANDLE)((UINTN)FmSet->CallbackHandle) ) + { + Status = gBS->HandleProtocol( + (EFI_HANDLE)((UINTN)FmSet->CallbackHandle), + &gEfiFormCallbackProtocolGuid, + &FormCallBack ); + } + + if ( ! EFI_ERROR( Status ) ) + { + if( FormCallBack->NvRead ) + { + Status = FormCallBack->NvRead( FormCallBack, name, guid, attributes, size, *buffer ); + + if ( Status != EFI_BUFFER_TOO_SMALL ) + break; + + *buffer = EfiLibAllocatePool( *size ); + + if ( *buffer == NULL ) + return EFI_OUT_OF_RESOURCES; + + Status = FormCallBack->NvRead( FormCallBack, name, guid, attributes, size, *buffer ); + break; + } + else + Status = EFI_UNSUPPORTED; + } + } + } + + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiFormCallbackNVWrite +// +// Description: Function to get callback nvwrite +// +// Input: CHAR16 *name, +// EFI_GUID *guid, +// UINT32 *attributes, +// VOID **buffer +// UINTN *size, +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size) +{ + EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL; + BOOLEAN Reset=FALSE; + EFI_STATUS Status = EFI_UNSUPPORTED; + EFI_IFR_FORM_SET * FmSet=NULL; + UINTN i=0; + + if(gSetupCount) + { + for ( i = 0; i < gSetupCount - 1; i++ ) + { + FmSet = HiiGetFormSet( i ); + + if(!FmSet) + continue; + + if( EfiCompareGuid(&(FmSet->Guid),guid) && (EFI_HANDLE)((UINTN)FmSet->CallbackHandle) ) + { + Status = gBS->HandleProtocol( + (EFI_HANDLE)((UINTN)FmSet->CallbackHandle), + &gEfiFormCallbackProtocolGuid, + &FormCallBack ); + } + + if ( ! EFI_ERROR(Status ) ) + { + if( FormCallBack->NvWrite ) + { + Reset = FALSE; + Status = FormCallBack->NvWrite( + FormCallBack, + name, + guid, + attributes, + size, + buffer, + &Reset + ); + if ( ( ! EFI_ERROR(Status ) ) && Reset ) + gResetRequired = TRUE; + break; + } + else + Status = EFI_UNSUPPORTED; + } + } + } + return Status; + +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: InitMiniSetupStrings +// +// Description: Function to init minisetup strings +// +// Input: VOID +// +// Output: Status +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1 +EFI_STATUS InitMiniSetupStrings( VOID ) +{ + EFI_STATUS Status=EFI_SUCCESS; + UINT16 Index = 0; + +#if HII_VERSION == 0 + EFI_HII_PACK_LIST PackList; + EFI_HII_PACK_LIST *PackageList; +#else + EFI_HII_PACKAGES *PackageList = NULL; +#endif + VOID **Package = NULL; + EFI_GUID MiniSetupGuid = MINI_SETUP_GUID; + + Status = HiiInitializeProtocol(); + if ( EFI_ERROR ( Status ) ) + return Status; + + gHiiHandle = HiiFindHandle( &MiniSetupGuid, &Index ); + + if ( gHiiHandle == INVALID_HANDLE ) + { +#if HII_VERSION == 0 + PackList.IfrPack = NULL; + PackList.StringPack = (EFI_HII_STRING_PACK *)STRING_ARRAY_NAME; + PackList.FontPack = NULL; + PackList.KeyboardPack = NULL; + PackList.GuidId = &MiniSetupGuid; + PackageList = &PackList; +#else + PackageList = EfiLibAllocateZeroPool( sizeof(EFI_HII_PACKAGES) + sizeof(VOID *) ); + if ( PackageList == NULL ) + return EFI_OUT_OF_RESOURCES; + + PackageList->GuidId = &MiniSetupGuid; + PackageList->NumberOfPackages = 1; + Package = (VOID **) ((UINT8 *)PackageList + sizeof (EFI_HII_PACKAGES)); +#ifdef USE_DEPRICATED_INTERFACE + *Package = (VOID *)STRING_ARRAY_NAME; +#else + *Package = (VOID *)&STRING_ARRAY_NAME; +#endif +#endif + + Status = gHiiProtocol->NewPack( gHiiProtocol, PackageList, (EFI_HII_HANDLE *)&gHiiHandle ); +#if HII_VERSION != 0 + MemFreePointer( (VOID **)&PackageList ); +#endif + } + + return Status; +} +#endif +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiIsEfiVariable +// +// Description: Function to check efi variable +// +// Input: UINT32 variable, VARIABLE_INFO *varInfo +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN UefiIsEfiVariable(UINT32 variable, VARIABLE_INFO *varInfo) +{ + return TRUE; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiVarGetNvram +// +// Description: Function to get nvram +// +// Parameter: VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset, +// UINTN Size +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiVarGetNvram(VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset, UINTN Size) +{ + return EFI_UNSUPPORTED; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiVarGetNvram +// +// Description: Function to set nvram +// +// Parameter: VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset, +// UINTN Size +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiVarSetNvram(VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset, UINTN Size) +{ + return EFI_UNSUPPORTED; +} + +#define AMI_FLAG_MANUFACTURING EFI_IFR_FLAG_MANUFACTURING +#define AMI_FLAG_DEFAULT EFI_IFR_FLAG_DEFAULT +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiGetManufactuingMask +// +// Description: Function to get manufacturing mask +// +// Input: VOID +// +// Output: UINTN +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINTN HiiGetManufactuingMask(VOID) +{ + return AMI_FLAG_MANUFACTURING; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: HiiGetDefaultMask +// +// Description: Function to get default mask +// +// Input: VOID +// +// Output: UINTN +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINTN HiiGetDefaultMask(VOID) +{ + return AMI_FLAG_DEFAULT; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetControlConditionVarId +// +// Description: Function to get control variable id +// +// Input: CONTROL_INFO *control +// +// Output: UINT32 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT32 GetControlConditionVarId(CONTROL_INFO *control) +{ + return (control->ControlConditionalVariable[0])?control->ControlConditionalVariable[0]:0xFFFF; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: BBSUpdateControlOffset +// +// Description: Function to update control offset +// +// Input: CONTROL_INFO *control +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID BBSUpdateControlOffset(CONTROL_INFO *control) +{ + UINT16 offset= ((EFI_IFR_ONE_OF*)control->ControlPtr)->QuestionId; + + offset = offset +sizeof(UINT32)+sizeof(UINT16); + offset = (UINT16)(offset + gCurrLegacyBootData->LegacyEntryOffset); + + ((EFI_IFR_ONE_OF*)control->ControlPtr)->QuestionId = offset; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetSpecialEqIDIfrPtr +// +// Description: Function to get special eqID Ifr pointer +// +// Input: VOID *Conditional, UINT32 Variable, GUID_INFO **GuidInfo +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID* UefiGetSpecialEqIDIfrPtr(CONTROL_INFO *ControlInfo, UINT32 *Variable, GUID_INFO **GuidInfo) +{ + VOID *Conditional = ControlInfo->ControlConditionalPtr; + VOID *ControlPtr = ControlInfo->ControlPtr; + EFI_IFR_OP_HEADER *ifrPtr; + VARIABLE_INFO *varInfo; + UINTN i; + GUID_INFO *specialGuid = NULL; + + ifrPtr = (EFI_IFR_OP_HEADER *)Conditional; + + if((ifrPtr==NULL) || (ControlPtr <= Conditional)) + return NULL; + + if ( ( ifrPtr->OpCode != EFI_IFR_SUPPRESS_IF_OP ) && ( ifrPtr->OpCode != EFI_IFR_GRAYOUT_IF_OP ) ) + return NULL; + + ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); + if ( ( ifrPtr->OpCode == EFI_IFR_VARSTORE_SELECT_OP ) || ( ifrPtr->OpCode == EFI_IFR_VARSTORE_SELECT_PAIR_OP ) ) + ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); + + // skip NOT if it is present + if ( ifrPtr->OpCode == EFI_IFR_NOT_OP ) + ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); + + if(NoVarStoreSupport()) + { + if(*Variable == VARIABLE_ID_SETUP) + { + *Variable = FindVarFromITKQuestionId(UefiGetEqIDQuestionID(ifrPtr)); + } + } + + varInfo = VarGetVariableInfoIndex( *Variable ); + if ( varInfo == NULL ) + return NULL; + + for ( i = 0; i < gGuidList->GuidCount; i++ ) + { + GUID_INFO *guidInfo = (GUID_INFO *)((UINTN)gGuidList + gGuidList->GuidList[i]); + if ( EfiCompareGuid( &varInfo->VariableGuid, &guidInfo->GuidValue ) ) + { + specialGuid = guidInfo; + break; + } + } + + if ( specialGuid != NULL ) + { + if ( GuidInfo != NULL ) + *GuidInfo = specialGuid; + } + else + { + ifrPtr = NULL; + } + + // See if Other condition is Special condition + if(ifrPtr == NULL) + { + if(ControlPtr > Conditional) + { + ifrPtr = (EFI_IFR_OP_HEADER *)Conditional; + ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); // To skip the SuppressIf or GrayOutIf + // to skip current expression. + while( (VOID*)ifrPtr < ControlPtr) + { + if ( (ifrPtr != ControlPtr) && ( ifrPtr->OpCode != EFI_IFR_SUPPRESS_IF_OP ) && ( ifrPtr->OpCode != EFI_IFR_GRAYOUT_IF_OP ) ) + ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); // To skip the SuppressIf or GrayOutIf + else + break; + } + + Conditional = ifrPtr; + if(ControlPtr > Conditional) + { + CONTROL_INFO TempCtlInfo; + MemCopy(&TempCtlInfo, ControlInfo, sizeof (CONTROL_INFO)); + TempCtlInfo.ControlConditionalPtr = Conditional; + ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); // To skip the SuppressIf or GrayOutIf + if ( ( ifrPtr->OpCode == EFI_IFR_VARSTORE_SELECT_OP ) ) + VarGetVariableInfoId( ((EFI_IFR_VARSTORE_SELECT*)((char*)ifrPtr))->VarId, Variable ); + ifrPtr = UefiGetSpecialEqIDIfrPtr(&TempCtlInfo, Variable, GuidInfo); + } + else + ifrPtr = NULL; + } + } + + return ifrPtr; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetSpecialEqIDValue +// +// Description: Function to get special eqID value +// +// Input: CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetSpecialEqIDValue(CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo) +{ + UINT16 value = (UINT16)-2; + UINT32 condVarID = 0; + EFI_IFR_OP_HEADER *ifrPtr = NULL; + + condVarID = (UINT32)GetControlConditionVarId(ControlInfo); + ifrPtr = (EFI_IFR_OP_HEADER *)UefiGetSpecialEqIDIfrPtr(ControlInfo, &condVarID, GuidInfo); + + if(ifrPtr != NULL) + { + switch(ifrPtr->OpCode) + { + case EFI_IFR_EQ_ID_LIST_OP: + value = ((EFI_IFR_EQ_ID_LIST *)ifrPtr)->ValueList[0]; + break; + case EFI_IFR_EQ_ID_VAL_OP: + value = ((EFI_IFR_EQ_ID_VAL *)ifrPtr)->Value; + break; + default: + break; + } + } + + return value; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSpecialGuidCallback +// +// Description: Function to get special guid callback +// +// Input: VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSpecialGuidCallback(VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID) +{ + EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL; + EFI_IFR_FORM_SET *FormSet = NULL; + EFI_IFR_DATA_ARRAY callbackData; + EFI_STATUS Status; + + MemSet( &callbackData, sizeof(callbackData), 0 ); + + FormSet = HiiGetFormSetFromHandle( HiiHandle ); + + if ( FormSet != NULL ) + { + Status = gBS->HandleProtocol ( (EFI_HANDLE)((UINTN) FormSet->CallbackHandle), &gEfiFormCallbackProtocolGuid, &FormCallBack); + + if(!EFI_ERROR(Status)) + { + (VOID*)callbackData.NvRamMap = (VOID*)pGUID; + if ( ( FormCallBack != NULL ) && ( FormCallBack->Callback != NULL ) ) + FormCallBack->Callback( FormCallBack, Key, &callbackData, NULL ); + } + } + +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetEqIDValue +// +// Description: Function to set EqID value +// +// Input: VOID *IfrPtr, UINT16 Value +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSetEqIDValue(VOID *IfrPtr, UINT16 Value) +{ + EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr; + + switch(opHeader->OpCode) + { + case EFI_IFR_EQ_ID_LIST_OP: + ((EFI_IFR_EQ_ID_LIST *)IfrPtr)->ValueList[0] = Value; + break; + case EFI_IFR_EQ_ID_VAL_OP: + ((EFI_IFR_EQ_ID_VAL *)IfrPtr)->Value = Value; + break; + default: + break; + } +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiIsOneOfControl +// +// Description: Function to check for OneOf controls +// +// Input: VOID *IfrPtr +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN UefiIsOneOfControl(VOID *IfrPtr) +{ + return (((EFI_IFR_OP_HEADER *)IfrPtr)->OpCode == EFI_IFR_ONE_OF_OP)? TRUE : FALSE; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetEqIDQuestionID +// +// Description: Function to check EqID question ID +// +// Input: VOID *IfrPtr +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetEqIDQuestionID(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr; + UINT16 questionID = 0; + + switch(opHeader->OpCode) + { + case EFI_IFR_EQ_ID_ID_OP: + break; + case EFI_IFR_EQ_ID_LIST_OP: + questionID = ((EFI_IFR_EQ_ID_LIST *)opHeader)->QuestionId; + break; + case EFI_IFR_EQ_ID_VAL_OP: + questionID = ((EFI_IFR_EQ_ID_VAL *)opHeader)->QuestionId; + break; + default: + break; + } + + return questionID; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetEqIDQuestionID +// +// Description: Function to set EqID question ID +// +// Input: VOID *IfrPtr, UINT16 Value +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSetEqIDQuestionID(VOID *IfrPtr, UINT16 Value) +{ + EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr; + + switch(opHeader->OpCode) + { + case EFI_IFR_EQ_ID_ID_OP: + break; + case EFI_IFR_EQ_ID_LIST_OP: + ((EFI_IFR_EQ_ID_LIST *)opHeader)->QuestionId = Value; + break; + case EFI_IFR_EQ_ID_VAL_OP: + ((EFI_IFR_EQ_ID_VAL *)opHeader)->QuestionId = Value; + break; + default: + break; + } +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiCreateOneOfWithOptionsTemplate +// +// Description: Function to create OneOf option template +// +// Input: UINTN OptionCount, CONTROL_INFO *CtrlInfo +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID* UefiCreateOneOfWithOptionsTemplate(UINTN OptionCount, CONTROL_INFO *CtrlInfo) +{ + VOID *buffer = NULL; + UINTN length = 0; + UINTN offset = (UINTN)CtrlInfo->ControlPtr - (UINTN)CtrlInfo->ControlConditionalPtr; + UINT32 size = (UINT32)((UINT32)offset + sizeof(EFI_IFR_ONE_OF) + sizeof(EFI_IFR_END_ONE_OF) + OptionCount * sizeof(EFI_IFR_ONE_OF_OPTION)); + + buffer = EfiLibAllocateZeroPool(size); + if(buffer == NULL) + { + goto DONE; + } + MemCopy(buffer, CtrlInfo->ControlConditionalPtr, offset); + + length = UefiGetIfrLength(CtrlInfo->ControlPtr); + CtrlInfo->ControlConditionalPtr = buffer; + MemCopy( (UINT8 *)buffer + offset, CtrlInfo->ControlPtr, length ); + CtrlInfo->ControlPtr = (UINT8 *)buffer + offset; +DONE: + return (buffer == NULL)?NULL:((UINT8*)buffer + offset); +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetOneOfOption +// +// Description: Function to set OneOf option +// +// Input: VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiSetOneOfOption(VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option) +{ + EFI_IFR_ONE_OF_OPTION *option = (EFI_IFR_ONE_OF_OPTION *)IfrPtr; + UINT8 flag = 0; + + flag |= ((Flag & AMI_FLAG_DEFAULT) == AMI_FLAG_DEFAULT)? EFI_IFR_FLAG_DEFAULT : 0; + flag |= ((Flag & AMI_FLAG_MANUFACTURING) == AMI_FLAG_MANUFACTURING)? EFI_IFR_FLAG_MANUFACTURING : 0; + + option->Value = (UINT16)Value; + option->Option = Option; + option->Flags = flag; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiUpdateControlVarOffset +// +// Description: Function to update control variable offset +// +// Input: VOID *IfrPtr, UINT16 Value +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiUpdateControlVarOffset(VOID *IfrPtr, UINT16 Value) +{ + EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr; + + switch(opHeader->OpCode) + { + case EFI_IFR_ONE_OF_OP: + ((EFI_IFR_ONE_OF *)opHeader)->QuestionId = Value; + break; + default: + break; + } +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiAddEndOp +// +// Description: Function to add end op code +// +// Input: VOID *IfrPtr +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiAddEndOp(VOID *IfrPtr) +{ + EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr; + + opHeader->OpCode = EFI_IFR_END_OP; + opHeader->Length = sizeof(EFI_IFR_OP_HEADER); +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetQuestionID +// +// Description: Function to get question ID +// +// Input: CONTROL_INFO *control +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetQuestionID(CONTROL_INFO *control) +{ + return UefiGetQuestionOffset(control->ControlPtr); +} +#pragma warning( disable : 4204 ) +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiCreateDynamicControlCondition +// +// Description: Function to create dynamic control condition +// +// Input: CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiCreateDynamicControlCondition(CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value) +{ + struct SuppressCondition + { + EFI_IFR_SUPPRESS Suppress; + EFI_IFR_VARSTORE_SELECT VarStroreSelect; + EFI_IFR_EQ_ID_VAL IDEqVal; + EFI_IFR_END_IF Endif; + }Condition= { {EFI_IFR_SUPPRESS_IF_OP,sizeof(EFI_IFR_SUPPRESS),0}, + {EFI_IFR_VARSTORE_SELECT_OP,sizeof(EFI_IFR_VARSTORE_SELECT),0}, + {EFI_IFR_EQ_ID_VAL_OP,sizeof(EFI_IFR_EQ_ID_VAL),0,sizeof(UINT16),Value }, + {EFI_IFR_END_IF_OP,sizeof(EFI_IFR_END_IF)}}; + + Condition.VarStroreSelect.VarId = VarId; + Condition.IDEqVal.QuestionId = PrevControlQuestionID; +// Add the New code to update the ControlConditionalPtr + MemCopy((void*)control->ControlConditionalPtr,(void*)&Condition,sizeof(Condition)); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiCreateStringTemplate +// +// Description: Function to create uefi string template +// +// Parameter: UINT16 Token +// +// Return value: VOID * +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID * UefiCreateStringTemplate(UINT16 Token) +{ + EFI_IFR_OP_HEADER *OpHeader = EfiLibAllocateZeroPool(sizeof(EFI_IFR_STRING)); + + OpHeader->OpCode = EFI_IFR_STRING_OP ; + OpHeader->Length = sizeof(EFI_IFR_STRING) ; + UefiSetPromptField((VOID *)OpHeader,Token); + return (VOID*)OpHeader; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: ProcessActionQuestionConfiguration +// +// Description: Function to process Action Control Configuration String. +// UEFI Action control is a 2.1 control +// +// Input: CONTROL_INFO *control +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS ProcessActionQuestionConfiguration(CONTROL_INFO *control) +{ + return EFI_SUCCESS; +} + +//EIP 23354 : Start +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: IsPasswordEncodeEnabled +// +// Description: Function to Password Encoding Status. +// +// Input: VOID *PwDataPtr +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN IsPasswordEncodeEnabled ( CONTROL_INFO * controlInfo ) +{ + EFI_IFR_PASSWORD *PwData = ((EFI_IFR_PASSWORD *)controlInfo->ControlPtr); + return (PwData->Encoding == TRUE)? TRUE:FALSE; +} +//EIP 23354 : End +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetTime +// +// Description: Function to get time +// +// Parameter: CONTROL_INFO *control, EFI_TIME *Tm +// +// Return value: STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiGetTime(CONTROL_INFO *control, EFI_TIME *Tm) +{ + return gRT->GetTime( Tm, NULL ); +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiSetTime +// +// Description: Function to set time +// +// Parameter: CONTROL_INFO *control, EFI_TIME *Tm +// +// Return value: STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiSetTime(CONTROL_INFO *control, EFI_TIME *Tm) +{ + return gRT->SetTime( Tm ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UefiIsProceedWithPageChange +// +// Description: For UEFI 2.0 Just return EFI_SUCCESS; +// +// Parameter: EFI_STATUS +// +// Return Value: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiIsProceedWithPageChange(EFI_STATUS Status) +{ + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UefiPreControlUpdate +// +// Description: In UEFI 2.0 this is Dummy function. +// +// Parameter: CONTROL_INFO * ControlData +// +// Return Value: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiPreControlUpdate(CONTROL_INFO *ControlData) +{ + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiRefershQuestionValueNvRAM +// +// Description: Function Refresh the question +// +// Parameter: CONTROL_INFO *control +// +// Return value: STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiRefershQuestionValueNvRAM(CONTROL_INFO *ControlData) +{ + return EFI_SUCCESS; +} + +//EIP:56413 START +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiupdateResetButtonDefault +// +// Description: In UEFI 2.0 this is Dummy function. +// +// Input: CONTROL_INFO ControlData, UINT16 DefaultId +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UefiupdateResetButtonDefault(CONTROL_INFO ControlData, UINT16 DefaultId) +{ + return EFI_SUCCESS; +} + +//EIP:56413: START +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UefiGetResetButtonDefaultid +// +// Description: In UEFI 2.0 this is Dummy function. +// +// Parameter: VOID *IfrPtr +// +// Return value: UINT16 +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 UefiGetResetButtonDefaultid(VOID *IfrPtr) +{ +return 0xffff; +} +//EIP:56413 END + +//EIP: 55762 Start +//<AMI_PHDR_START> +//--------------------------------------------------------------------------- +// Procedure: UpdateDestiantionQuestion +// +// Description: Dummy function for 2.0 +// +// Input: UINT32 CurrPageID - Current page ID +// UINT32 DestQuestionId - Destination question ID to set focus +// UINT32 *FocusControlIndex - +// +// Output: EFI_STATUS status - EFI_SUCCESS is successful +//--------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS UpdateDestiantionQuestion (UINT32 CurrPageID, UINT32 DestQuestionId, UINT32 *FocusControlIndex) +{ + return EFI_UNSUPPORTED; +} +//EIP: 55762 End + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: FindDriverHealthDriverName +// +// Description: Finds the driver name which supports driver health protocol +// +// Input: UINT16 = Entry for which driver name has to be return +// +// Output: CHAR16 * = Driver Name +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +CHAR16 *FindDriverHealthDriverName (UINT16 DriverEntry) +{ + return NULL; +} + +//<AMI_PHDR_START> +//----------------------------------------------------------------------------------------------------- +// Procedure: CtrlsSupportsHealthProtocol +// +// Description: Finds the number of controllers supports driver health protocol for the driver entry +// +// Input: UINT16 = Entry for driver to which total controllers has to be find +// +// Output: UINT16 = Total number of controllers supports driver health +// +//----------------------------------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 CtrlsSupportsHealthProtocol (UINT16 EntryItem) +{ + return 0; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------------- +// Procedure: GetCtrlNameAndHealth +// +// Description: Finds the controller name with its health +// +// Input: UINT16 = Entry for controller to which name has to be find +// +// Output: CHAR16 * = Controller name with its health status +// +//----------------------------------------------------------------------------------- +//<AMI_PHDR_END> +CHAR16 *GetCtrlNameAndHealth (UINT16 ControllerEntry) +{ + return NULL; +} + +//<AMI_PHDR_START> +//------------------------------------------------------------------------------------------- +// Procedure: SetDrvHealthHandleAndCtrlCount +// +// Description: Finds and sets the number of controllers supports the driver health handle +// +// Input: UINT16 = Driver health handle entry +// +// Output: VOID +// +//-------------------------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID SetDrvHealthHandleAndCtrlCount (UINT16 ItemEntry) +{ +} + +//EIP57661 Starts +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: SetDriverHealthCount +// +// Description: Sets the DriverHealthCount and DriverHlthEnable variables +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID SetDriverHealthCount (VOID) +{ +} + +//<AMI_PHDR_START> +//------------------------------------------------------------------------------------------- +// Procedure: DoDriverHealthOperation +// +// Description: Performs the driver health operations for the corresponding controller entry +// +// Input: VOID * = Control Info for the correponding controller entry +// UINT16 = Controller entry in the page +// +// Output: VOID +// +//-------------------------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID DoDriverHealthOperation (VOID *Tempcontrol, UINT16 ControllerEntry) +{ +} + +//<AMI_PHDR_START> +//--------------------------------------------------------------------------- +// Procedure: UefiGetValidOptionSize +// +// Description: Function to get sizeof option.UEFI2.0 doesn't have EFI_IFR_TYPE support +// +// Input: CONTROL_INFO *CtrlInfo - Pointer to the control info data +// UINTN *Type - Returns EFI_IFR_TYPE_NUM_SIZE +// +// Output: VOID +//--------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UefiGetValidOptionType(CONTROL_INFO *CtrlInfo, UINTN *Type, UINT32 *SizeOfData) +{ + *SizeOfData = sizeof(UINT8);//UEFI2.0 Supports UINT8 size of data for OrderList Control +} +//<AMI_PHDR_START> +//--------------------------------------------------------------------------- +// Procedure: CheckTimeFlags +// +// Description: Function to check the time flags. +// +// Input: UINT8 Flags +// +// Output: BOOLEAN +//--------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN CheckTimeFlags(UINT8 Flags) +{ + return FALSE; +} + +//<AMI_PHDR_START> +//--------------------------------------------------------------------------- +// Procedure: CheckDateFlags +// +// Description: Function to check the Date flags. +// +// Input: UINT8 Flags +// +// Output: BOOLEAN +//--------------------------------------------------------------------------- +//<AMI_PHDR_END> +BOOLEAN CheckDateFlags(UINT8 Flags) +{ + return FALSE; +} + +//<AMI_PHDR_START> +//--------------------------------------------------------------------------- +// Procedure: ProcessPackNotification +// +// Description: Processes the IFR notification queue +// +// Input: None +// +// Output: EFI_STATUS status - EFI_ABORTED, By default +// EFI_SUCCESS, if successful +// EFI_ERROR, otherwise +//--------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS ProcessPackNotification (VOID) +{ + return EFI_ABORTED; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: RegFormNotification +// +// Description: Registers the hii pack notification +// +// Parameter: VOID +// +// Return value: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS RegFormNotification (VOID) +{ + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UnRegFormNotification +// +// Description: Unregisters the form notification +// +// Parameter: VOID +// +// Return value: VOID +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +VOID UnRegFormNotification (VOID) +{ + +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: EvaluateControlDefault +// +// Description: +// +// Parameter: CONTROL_INFO *CtrlInfo +// +// Return value: UINT64 +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT16 EvaluateControlDefault (CONTROL_INFO *CtrlInfo, UINT64 *Defaults) +{ + return 0; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + |