summaryrefslogtreecommitdiff
path: root/Board/EM/FixedBootOrder
diff options
context:
space:
mode:
Diffstat (limited to 'Board/EM/FixedBootOrder')
-rw-r--r--Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.c843
-rw-r--r--Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.cif12
-rw-r--r--Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.mak107
-rw-r--r--Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sd962
-rw-r--r--Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sdl88
-rw-r--r--Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.unibin0 -> 17928 bytes
-rw-r--r--Board/EM/FixedBootOrder/FBOSetOrder.c1699
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrder.c3149
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrder.chmbin0 -> 120169 bytes
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrder.h309
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrder.mak138
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrder.sdl280
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrderHII.c888
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrderHII.h128
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.c482
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.cif10
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.mak95
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.sdl51
-rw-r--r--Board/EM/FixedBootOrder/FixedBootOrderTSE.c1478
19 files changed, 10719 insertions, 0 deletions
diff --git a/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.c b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.c
new file mode 100644
index 0000000..7d7eb17
--- /dev/null
+++ b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.c
@@ -0,0 +1,843 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/DefaultFixedBootOrder.c $
+//
+// $Author: Walonli $
+//
+// $Revision: 7 $
+//
+// $Date: 8/13/14 11:20p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/DefaultFixedBootOrder.c $
+//
+// 7 8/13/14 11:20p Walonli
+// [TAG] EIP180632
+// [Category] New Feature
+// [Description] Add FixedBootOrder Protocol to change device/group
+// name.
+// [Files] DefaultFixedBootOrder.sdl
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.mak
+// DefaultFixedBootOrder.cif
+//
+// 6 8/12/13 4:25a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] CppCheck error fix.
+// [Files] DefaultFixedBootOrder.c
+//
+// 5 5/31/13 2:33a Easonchen
+// [TAG] EIP123284
+// [Category] Improvement
+// [Description] Set Boot Priority unicode string
+// [Files] FixedBootOrder.c
+// FixedBootOrder.h
+// FixedBootOrder.sdl
+// FixedBootOrderTSE.c
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 4 5/28/13 5:29a Easonchen
+// [TAG] EIP122146
+// [Category] Improvement
+// [Description] Support Dual mode default priority with tool AMIBCP.
+// [Files]
+// FboSetOrder.c
+// FixedBootOrder.c
+// FixedBoorOrderTse.c
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 3 4/22/13 11:20p Easonchen
+// [TAG] EIP101213
+// [Category] Improvement
+// [Description] FixedBootOrder should match the BootOrder variable
+// [Files] FboSetOrder.c
+// FixedBootOrder.sdl
+// DefaultFixedBootOrder.c
+//
+// 2 10/04/12 2:17a Easonchen
+// [TAG] EIP96232
+// [Category] Improvement
+// [Description] Support USB Floppy in UEFI mode
+// [Files] FixedBootOrder.h
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 1 6/28/12 11:41a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+// functionality.
+//
+//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------
+//
+// Name: DefaultFixedBootOrder.c
+//
+// Description: Default FixedBootOrder Boot type setting.
+//
+//----------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+//----------------------------------------------------------------------
+// Include Files
+//----------------------------------------------------------------------
+#include <efi.h>
+#include <amidxelib.h>
+#include <BootOptions.h>
+#include <protocol\PciIo.h>
+#if CSM_SUPPORT
+#include <Protocol\LegacyBios.h>
+#endif
+#include <protocol\PciRootBridgeIo.h>
+#include <protocol\PDiskInfo.h>
+#include <PciHostBridge.h>
+#include <Setup.h>
+#include "FixedBootOrder.h"
+#include "SetupStrTokens.h"
+#include "Build/DefaultFixedBootOrder.h"
+//---------------------------------------------------------------------------
+// Global Variable declarations
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+// External functions
+//---------------------------------------------------------------------------
+EFI_HANDLE GetPhysicalBlockIoHandle(EFI_HANDLE BlockIoHandle);
+BOOLEAN IsUSBkeyByHandle(EFI_HANDLE Handle);
+BOOLEAN IsShellBootOption(BOOT_OPTION *Option);
+UINT32 FBO_FindTagPriority(UINT16 Tag);
+//---------------------------------------------------------------------------
+// Global Variable declarations
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+// Function Definitions
+//---------------------------------------------------------------------------
+UINT32 GetUefiBootOptionTag(IN EFI_DEVICE_PATH_PROTOCOL *Dp) ;
+EFI_STATUS SetDevNewDescription(EFI_DEVICE_PATH_PROTOCOL *DpHead, CHAR16 *Description) ;
+//---------------------------------------------------------------------------
+// Type definitions
+//---------------------------------------------------------------------------
+typedef VOID (FBO_CHANGE_DEVICE_NAME)(FBO_DEVICE_INFORM *Content);
+extern FBO_CHANGE_DEVICE_NAME FBO_CHANGE_DEVICE_NAME_FUNCS EndOfFboChangeDeviceName ;
+FBO_CHANGE_DEVICE_NAME *FboChangeDeviceNameFuncs[] = { FBO_CHANGE_DEVICE_NAME_FUNCS NULL } ;
+
+#ifndef EFI_PCI_CFG_ADDRESS
+#define EFI_PCI_CFG_ADDRESS(bus,dev,func,reg) \
+ ((UINT64) ( (((UINTN)bus) << 24)+(((UINTN)dev) << 16) + (((UINTN)func) << 8) + ((UINTN)reg)))& 0x00000000ffffffff
+#endif
+#define offsetof(type, member) ( (int) & ((type*)0) -> member )
+//---------------------------------------------------------------------------
+// Constant and Variables declarations
+//---------------------------------------------------------------------------
+typedef enum{
+// BoTagLegacyXxx
+// BoTagUefiXxx
+// BoTagXxx
+//--standard device type don't modify--//
+ BoTagLegacyFloppy = 1, //1
+ BoTagLegacyHardDisk, //2
+ BoTagLegacyCdrom, //3
+ BoTagLegacyPcmcia, //4
+ BoTagLegacyUsb, //5
+ BoTagLegacyEmbedNetwork, //6
+ BoTagLegacyBevDevice = 0x80,//7
+//--standard device type don't modify--// end
+ BoTagLegacyUSBFloppy = 8,
+ BoTagLegacyUSBHardDisk,
+ BoTagLegacyUSBCdrom,
+ BoTagLegacyUSBKey,
+ BoTagUefiUSBFloppy, //(EIP96232+)
+ BoTagUefiHardDisk,
+ BoTagUefiCdrom,
+ BoTagUefiUsbHardDisk,
+ BoTagUefiUsbKey,
+ BoTagUefiUsbCdrom,
+ BoTagUefiNetWork,
+ BoTagUefi,
+ BoTagEmbeddedShell
+} FIXED_BOOT_OPTION_TAG;
+
+
+FIXED_BOOT_OPTION_TAG FixedLegacyBootOptionTags[] = {
+ 0,
+ BoTagLegacyFloppy,
+ BoTagLegacyHardDisk,
+ BoTagLegacyCdrom,
+ BoTagLegacyPcmcia,
+ BoTagLegacyUsb,
+ BoTagLegacyEmbedNetwork,
+ BoTagLegacyBevDevice,
+ BoTagLegacyUSBFloppy,
+ BoTagLegacyUSBHardDisk,
+ BoTagLegacyUSBCdrom,
+ BoTagLegacyUSBKey,
+ UNASSIGNED_HIGHEST_TAG
+};
+
+FBODevMap FBOUefiDevMapData[]={
+ { BoTagUefiHardDisk, 0, 0xff, 0},
+ { BoTagUefiCdrom, 0, 0xff, 0},
+ { BoTagUefiUsbHardDisk, 0, 0xff, 0},
+ { BoTagUefiUsbCdrom, 0, 0xff, 0},
+ { BoTagUefiUsbKey, 0, 0xff, 0},
+ { BoTagUefiUSBFloppy, 0, 0xff, 0}, //(EIP96232+)
+ { BoTagUefiNetWork, 0, 0xff, 0},
+ { 0, 0 } //end of data
+};
+
+#if CSM_SUPPORT
+FBODevMap FBOLegacyDevMapData[]={
+
+ { BoTagLegacyHardDisk, BBS_HARDDISK, 0xff, 0},
+ { BoTagLegacyCdrom, BBS_CDROM, 0xff, 0},
+ { BoTagLegacyUSBHardDisk, BBS_HARDDISK, 0xff, F_USB},
+ { BoTagLegacyUSBCdrom, BBS_CDROM, 0xff, F_USB},
+ { BoTagLegacyUSBKey, BBS_HARDDISK, 0xff, F_USB | F_USBKEY},
+ { BoTagLegacyUSBFloppy, BBS_FLOPPY, 0xff, F_USB},
+ { BoTagLegacyEmbedNetwork, BBS_EMBED_NETWORK, 0xff, 0},
+ { 0, 0 } //end of data
+};
+
+FBODevMap FBODualDevMapData[]={
+ { BoTagUefiHardDisk, 0, 0xff, 0},
+ { BoTagUefiCdrom, 0, 0xff, 0},
+ { BoTagUefiUsbHardDisk, 0, 0xff, 0},
+ { BoTagUefiUsbCdrom, 0, 0xff, 0},
+ { BoTagUefiUsbKey, 0, 0xff, 0},
+ { BoTagUefiUSBFloppy, 0, 0xff, 0}, //(EIP96232+)
+ { BoTagUefiNetWork, 0, 0xff, 0},
+
+ { BoTagLegacyHardDisk, BBS_HARDDISK, 0xff, 0},
+ { BoTagLegacyCdrom, BBS_CDROM, 0xff, 0},
+ { BoTagLegacyUSBHardDisk, BBS_HARDDISK, 0xff, F_USB},
+ { BoTagLegacyUSBCdrom, BBS_CDROM, 0xff, F_USB},
+ { BoTagLegacyUSBKey, BBS_HARDDISK, 0xff, F_USB | F_USBKEY},
+ { BoTagLegacyUSBFloppy, BBS_FLOPPY, 0xff, F_USB},
+ { BoTagLegacyEmbedNetwork, BBS_EMBED_NETWORK, 0xff, 0},
+ { 0, 0 } //end of data
+};
+#endif
+
+#if (FBO_DUAL_MODE == 1) && (CSM_SUPPORT == 1)
+FBOHiiMap FBOHiiMapData[]={
+ { BoTagLegacyHardDisk, STR_BOOT_HDD, HDD_BOOT_FORM_ID, HDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyHDD)},
+ { BoTagLegacyCdrom, STR_BOOT_CDROM, ODD_BOOT_FORM_ID, ODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyODD)},
+ { BoTagLegacyEmbedNetwork, STR_BOOT_NETWORK, NET_BOOT_FORM_ID, NET_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyNET)},
+ { BoTagLegacyUSBFloppy, STR_BOOT_USBFDD, USBFDD_BOOT_FORM_ID, USBFDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBFDD)},
+ { BoTagLegacyUSBHardDisk, STR_BOOT_USBHDD, USBHDD_BOOT_FORM_ID, USBHDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBHDD)},
+ { BoTagLegacyUSBCdrom, STR_BOOT_USBODD, USBODD_BOOT_FORM_ID, USBODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBODD)},
+ { BoTagLegacyUSBKey, STR_BOOT_USBKEY, USBKEY_BOOT_FORM_ID, USBKEY_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBKEY)},
+ { BoTagUefiHardDisk, STR_DUAL_BOOT_UEFI_HDD, UEFI_HDD_BOOT_FORM_ID, UEFI_HDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiHDD)},
+ { BoTagUefiCdrom, STR_DUAL_BOOT_UEFI_CDROM, UEFI_ODD_BOOT_FORM_ID, UEFI_ODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiODD)},
+ { BoTagUefiNetWork, STR_DUAL_BOOT_UEFI_NETWORK, UEFI_NET_BOOT_FORM_ID, UEFI_NET_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiNET)},
+ { BoTagUefiUsbHardDisk, STR_DUAL_BOOT_UEFI_USBHDD, UEFI_USBHDD_BOOT_FORM_ID, UEFI_USBHDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBHDD)},
+ { BoTagUefiUsbCdrom, STR_DUAL_BOOT_UEFI_USBODD, UEFI_USBODD_BOOT_FORM_ID, UEFI_USBODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBODD)},
+ { BoTagUefiUsbKey, STR_DUAL_BOOT_UEFI_USBKEY, UEFI_USBKEY_BOOT_FORM_ID, UEFI_USBKEY_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBKEY)},
+ { BoTagUefiUSBFloppy, STR_DUAL_BOOT_UEFI_USBFDD, UEFI_USBFDD_BOOT_FORM_ID, UEFI_USBFDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBFDD)}, //(EIP96232+)
+ { 0, 0 } //end of data
+};
+#else
+FBOHiiMap FBOHiiMapData[]={
+ { BoTagLegacyHardDisk, STR_BOOT_HDD, HDD_BOOT_FORM_ID, HDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyHDD)},
+ { BoTagLegacyCdrom, STR_BOOT_CDROM, ODD_BOOT_FORM_ID, ODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyODD)},
+ { BoTagLegacyEmbedNetwork, STR_BOOT_NETWORK, NET_BOOT_FORM_ID, NET_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyNET)},
+ { BoTagLegacyUSBFloppy, STR_BOOT_USBFDD, USBFDD_BOOT_FORM_ID, USBFDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBFDD)},
+ { BoTagLegacyUSBHardDisk, STR_BOOT_USBHDD, USBHDD_BOOT_FORM_ID, USBHDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBHDD)},
+ { BoTagLegacyUSBCdrom, STR_BOOT_USBODD, USBODD_BOOT_FORM_ID, USBODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBODD)},
+ { BoTagLegacyUSBKey, STR_BOOT_USBKEY, USBKEY_BOOT_FORM_ID, USBKEY_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, LegacyUSBKEY)},
+ { BoTagUefiHardDisk, STR_BOOT_UEFI_HDD, UEFI_HDD_BOOT_FORM_ID, UEFI_HDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiHDD)},
+ { BoTagUefiCdrom, STR_BOOT_UEFI_CDROM, UEFI_ODD_BOOT_FORM_ID, UEFI_ODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiODD)},
+ { BoTagUefiNetWork, STR_BOOT_UEFI_NETWORK, UEFI_NET_BOOT_FORM_ID, UEFI_NET_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiNET)},
+ { BoTagUefiUsbHardDisk, STR_BOOT_UEFI_USBHDD, UEFI_USBHDD_BOOT_FORM_ID, UEFI_USBHDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBHDD)},
+ { BoTagUefiUsbCdrom, STR_BOOT_UEFI_USBODD, UEFI_USBODD_BOOT_FORM_ID, UEFI_USBODD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBODD)},
+ { BoTagUefiUsbKey, STR_BOOT_UEFI_USBKEY, UEFI_USBKEY_BOOT_FORM_ID, UEFI_USBKEY_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBKEY)},
+ { BoTagUefiUSBFloppy, STR_BOOT_UEFI_USBFDD, UEFI_USBFDD_BOOT_FORM_ID, UEFI_USBFDD_BOOT_FORM_LABEL, offsetof(FIXED_BOOT_GROUP, UefiUSBFDD)}, //(EIP96232+)
+ { 0, 0 } //end of data
+};
+#endif
+ //(EIP123284+)>
+UINT16 BootOptionStringToken[]={
+ STR_BOOT_ORDER_1,
+ STR_BOOT_ORDER_2,
+ STR_BOOT_ORDER_3,
+ STR_BOOT_ORDER_4,
+ STR_BOOT_ORDER_5,
+ STR_BOOT_ORDER_6,
+ STR_BOOT_ORDER_7,
+ STR_BOOT_ORDER_8,
+ STR_BOOT_ORDER_9,
+ STR_BOOT_ORDER_10,
+ STR_BOOT_ORDER_11,
+ STR_BOOT_ORDER_12,
+ STR_BOOT_ORDER_13,
+ STR_BOOT_ORDER_14,
+ STR_BOOT_ORDER_15,
+ STR_BOOT_ORDER_16
+};
+ //<(EIP123284+)
+
+EFI_STATUS DefaultFixedBootOrder_Init(IN void)
+{
+ EFI_STATUS Status;
+ EFI_GUID FixedBootOrderGuid=FIXED_BOOT_ORDER_GUID;
+ EFI_FIXED_BOOT_ORDER_PROTOCOL *pFBO=NULL;
+
+ Status = pBS->LocateProtocol( &FixedBootOrderGuid, NULL, &pFBO );
+ if( !EFI_ERROR(Status) )
+ {
+ pFBO->SetUefiDevMap( FBOUefiDevMapData );
+#if CSM_SUPPORT
+ pFBO->SetLegacyDevMap( FBOLegacyDevMapData );
+ pFBO->SetDualDevMap( FBODualDevMapData );
+#endif
+ pFBO->SetHiiMap( FBOHiiMapData );
+ pFBO->SetBootOptionTokenMap( BootOptionStringToken ); //(EIP123284+)
+ }
+ return Status;
+}
+
+#if CSM_SUPPORT
+//TODO:: OEM FUNCTION >>>
+//reference CRB SbSetup.c
+UINT16 gSATAAhci[6] = { 0, 1, 2, 3, 4, 5 };
+
+UINT16 gSATA[3][2] = {
+ { 0, 1 },
+ { 2, 3 },
+ { 4, 5 }
+};
+
+
+//Check ATA port number
+UINT16 CheckAhciSata(BBS_TABLE *BbsTable)
+{
+ EFI_STATUS Status;
+ EFI_GUID gEfiDiskInfoProtocolGuid = EFI_DISK_INFO_PROTOCOL_GUID;
+ EFI_DISK_INFO_PROTOCOL *DiskInfo;
+ UINT32 SataPortIndex;
+ UINT32 SataPMPort;
+ EFI_HANDLE Handle;
+
+ Handle = *(VOID**)(&BbsTable->IBV1);
+
+ Status = pBS->HandleProtocol ( Handle, &gEfiDiskInfoProtocolGuid, &DiskInfo );
+
+ if ( !EFI_ERROR(Status) )
+ {
+ Status = DiskInfo->WhichIde(
+ DiskInfo,
+ &SataPortIndex,
+ &SataPMPort
+ );
+
+ if( !EFI_ERROR(Status) )
+ return gSATAAhci[SataPortIndex];
+ }
+ return 0xff;
+}
+
+
+UINT16 CheckATAPortNumber(BBS_TABLE *BbsTable)
+{
+ EFI_STATUS Status;
+ EFI_GUID gEfiDiskInfoProtocolGuid = EFI_DISK_INFO_PROTOCOL_GUID;
+ EFI_DISK_INFO_PROTOCOL *DiskInfo;
+ UINT32 IdeChannel;
+ UINT32 IdeDevice;
+ EFI_HANDLE Handle;
+
+ Handle = *(VOID**)(&BbsTable->IBV1);
+
+ Status = pBS->HandleProtocol ( Handle, &gEfiDiskInfoProtocolGuid, &DiskInfo );
+
+ if ( !EFI_ERROR(Status) )
+ {
+ Status = DiskInfo->WhichIde ( DiskInfo, &IdeChannel, &IdeDevice );
+
+ if( !EFI_ERROR(Status) )
+ {
+ if( BbsTable->Function == 5 )
+ return gSATA[IdeDevice+2][IdeChannel];
+ else
+ return gSATA[IdeDevice][IdeChannel];
+ }
+ }
+ return 0xff;
+}
+
+UINT8 CheckSATAMode(BBS_TABLE *BbsTable)
+{
+ EFI_STATUS Status;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *gPciRootBridgeIo;
+
+ UINT8 PciData8;
+
+ Status = pBS->LocateProtocol(
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ &gPciRootBridgeIo
+ );
+
+ if(!EFI_ERROR(Status))
+ {
+ UINT32 PciBus, PciDevice, PciFunction;
+
+ PciBus=BbsTable->Bus;
+ PciDevice=BbsTable->Device;
+ PciFunction=BbsTable->Function;
+
+ gPciRootBridgeIo->Pci.Read(
+ gPciRootBridgeIo,
+ EfiPciIoWidthUint8,
+ EFI_PCI_CFG_ADDRESS(PciBus, PciDevice, PciFunction, 0x0a), //0A=PCI ClassCode Regsiter
+ 1,
+ &PciData8 );
+
+ return PciData8;
+ }
+
+ return 0xff;
+}
+
+UINT16 GetDevicePortNumber(BBS_TABLE *BbsTable)
+{
+ UINT16 PortNumber=0xff;
+
+// if( (BbsTable->Class!=0xc) && (BbsTable->SubClass!=0x3) )
+ if( BbsTable->DeviceType == BBS_HARDDISK )
+ {
+ switch (CheckSATAMode(BbsTable))
+ {
+ case 0x01: //IDE Class Code
+ PortNumber=CheckATAPortNumber(BbsTable);
+ break;
+
+ case 0x06: //AHCI Class Code
+ PortNumber=CheckAhciSata(BbsTable);
+ break;
+ }
+ }
+ return PortNumber;
+}
+//TODO:: OEM FUNCTION <<<
+#endif //#if CSM_SUPPORT
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FboChangeGroupName
+//
+// Description: Change Boot Option Group Name, OEM have two way to modify Group Name in run time, such as USB Key - > OEM USB Key
+// 1.Provide StrToken(Define in .uni), New Group Name.
+// FboChangeGroupName( STR_BOOT_HDD, NULL, NewGroupName) ;
+// 2.Provide Original Group Name(ex:Hard Disk), New Group Name.
+// FboChangeGroupName( 0, OrgGroupName, NewGroupName) ;
+//
+// Referrals: None
+//
+// Notes: EIP 143657
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+FboChangeGroupName(
+ IN OPTIONAL UINT16 StrToken,
+ IN OPTIONAL CHAR16* OrgGroupName,
+ IN CHAR16* NewGroupName )
+{
+ EFI_STATUS Status ;
+ UINT32 Attr ;
+ UINTN Size = 0 ,*GroupPtrAddr = NULL ;
+ FBO_GROUP_OPTION *Group = NULL ;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID ;
+
+ TRACE((-1,"DefaultFixedBootOrder.c FboChangeGroupName\n")) ;
+ if (StrToken == 0 && OrgGroupName == NULL )
+ return EFI_INVALID_PARAMETER ;
+
+ Status = GetEfiVariable(L"FboGroupNameData", &FixedBootOrderGuid, &Attr, &Size, &GroupPtrAddr);
+ if(EFI_ERROR(Status))
+ {
+ Group = MallocZ(sizeof(FBO_GROUP_OPTION)) ;
+ // Firsrt time, Restore the group pointer address to variable.
+ Status = pRS->SetVariable ( L"FboGroupNameData",
+ &FixedBootOrderGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(UINTN),
+ &Group );
+ }
+ else
+ {
+ // Go To the last node.
+ Group = (FBO_GROUP_OPTION*)*GroupPtrAddr ;
+ while (Group->Next)
+ Group = Group->Next ;
+ // Create the new node.
+ Group->Next = MallocZ(sizeof(FBO_GROUP_OPTION)) ;
+ Group = Group->Next ;
+ }
+
+ Group->NewGroupName = MallocZ( Wcslen(NewGroupName)*sizeof(CHAR16)+1) ;
+ Wcscpy( Group->NewGroupName, NewGroupName) ;
+ if (StrToken) Group->StrToken = StrToken ;
+ else
+ {
+ Group->OrgGroupName = MallocZ( Wcslen(OrgGroupName)*sizeof(CHAR16)+1) ;
+ Wcscpy( Group->OrgGroupName, OrgGroupName) ;
+ }
+ pBS->FreePool(GroupPtrAddr) ; // Avoid memory leak
+ return EFI_SUCCESS ;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetDevInform
+//
+// Description: Get Device Information(Description, Type, Path) by BootOptionList
+//
+// Input: FBO_DEVICE_INFORM **DevHead
+//
+// Output: FBO_DEVICE_INFORM **DevHead
+//
+// Notes: EIP 143657
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+GetDevInformByBootOptionList(
+ FBO_DEVICE_INFORM **DevHead)
+{
+ FBO_DEVICE_INFORM *DevInform = NULL;
+ EFI_DEVICE_PATH_PROTOCOL *Dp = NULL ;
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ EFI_STATUS Status ;
+ FOR_EACH_BOOT_OPTION(BootOptionList, Link, Option)
+ {
+ BOOLEAN UsbPortFlag = FALSE ;
+ if (Option->GroupHeader) continue ;
+ if (!DevInform)
+ *DevHead = DevInform = MallocZ(sizeof(FBO_DEVICE_INFORM)) ;
+ else
+ {
+ DevInform->Next = MallocZ(sizeof(FBO_DEVICE_INFORM)) ;
+ DevInform = DevInform->Next ;
+ }
+
+ DevInform->DevName = Option->Description ;
+ // Set Default value.
+ DevInform->DevPortNum = 0xff ;
+ DevInform->DevBDF = 0xffffffff ;
+
+ if (IsLegacyBootOption(Option))
+ {
+ // Legacy Option need use Handle Protocol to get correct Device Path.
+ Status = pBS->HandleProtocol((EFI_HANDLE)Option->BbsEntry->IBV1, &gEfiDevicePathProtocolGuid, &Dp);
+ if (EFI_ERROR(Status)) continue ;
+ DevInform->DevPath = Dp ;
+ DevInform->DevType = (UINT16)(0xff&Option->Tag) ;
+ DevInform->DevBDF = (UINT32) (Option->BbsEntry->Bus << 16)|
+ (Option->BbsEntry->Device << 11) |
+ (Option->BbsEntry->Function << 8);
+ }
+ else
+ {
+ UINT32 Bus = 0 ;
+ // Uefi Option just need get device path by Option->FilePathList.
+ DevInform->DevPath = Option->FilePathList ;
+ DevInform->DevType = (UINT16)GetUefiBootOptionTag(Option->FilePathList) ;
+
+ // Get Uefi Option BDF
+ Dp = DevInform->DevPath ;
+ while(!(isEndNode(Dp)))
+ {
+ if ( Dp->Type == ACPI_DEVICE_PATH && Dp->SubType == ACPI_DP )
+ {
+ Bus = ((ACPI_HID_DEVICE_PATH*)Dp)->UID ;
+ }
+ else if ( Dp->Type == HARDWARE_DEVICE_PATH && Dp->SubType == HW_PCI_DP )
+ {
+ DevInform->DevBDF = (UINT32) (Bus << 16) |
+ (((PCI_DEVICE_PATH*)Dp)->Device << 11) |
+ (((PCI_DEVICE_PATH*)Dp)->Function << 8);
+ break ;
+ }
+ Dp=NEXT_NODE(Dp) ;
+ }
+ }
+
+ // Get USB and SATA Port Number
+ Dp = DevInform->DevPath ;
+ while (!(isEndNode(Dp)))
+ {
+ if ( Dp->Type == MESSAGING_DEVICE_PATH && Dp->SubType == MSG_SATA_DP )
+ {
+ DevInform->DevPortNum = ((SATA_DEVICE_PATH*)Dp)->PortNumber ;
+ break ;
+ }
+ else if ( Dp->Type == MESSAGING_DEVICE_PATH && Dp->SubType == MSG_USB_DP )
+ {
+ if (!UsbPortFlag) UsbPortFlag = TRUE ;
+ else
+ {
+ DevInform->DevPortNum = (UINT16)((USB_DEVICE_PATH*)Dp)->ParentPortNumber ;
+ break ;
+ }
+ }
+ Dp=NEXT_NODE(Dp) ;
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SetDevNewDescription
+//
+// Description: Set Device New Description
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *DpHead
+// CHAR16 *Description
+// Output:
+//
+// Notes: OEM can use this function to update new device description.
+// example: SetDevNewDescription(Dp, L"OEM USB Key")
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+SetDevNewDescription(
+ EFI_DEVICE_PATH_PROTOCOL *DpHead,
+ CHAR16 *Description)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_FIXED_BOOT_ORDER_PROTOCOL*FBOProtocol ;
+ EFI_GUID FixedBootOrderGuid=FIXED_BOOT_ORDER_GUID;
+ Status = pBS->LocateProtocol (&FixedBootOrderGuid, NULL, &FBOProtocol);
+ if (!EFI_ERROR(Status))
+ {
+ // Prepare FBO_DEVICE_INFORM data
+ FBO_DEVICE_INFORM *SetData = MallocZ(sizeof(FBO_DEVICE_INFORM));
+ EFI_DEVICE_PATH_PROTOCOL *Dp = NULL ;
+ UINTN DpSize = 0 ;
+ Dp = DpHead ;
+ for ( ; !(isEndNode(Dp)) ; Dp=NEXT_NODE(Dp))
+ DpSize+=NODE_LENGTH(Dp) ;
+ DpSize += sizeof(EFI_DEVICE_PATH_PROTOCOL) ; //End Node Size
+
+ SetData->DevName = MallocZ(Wcslen(Description)*sizeof(CHAR16)+1) ;
+ SetData->DevPath = MallocZ(DpSize) ;
+ Wcscpy( SetData->DevName, Description);
+ MemCpy( SetData->DevPath, DpHead, DpSize);
+ // Set to new description.
+ Status = FBOProtocol->SetNewDescription( SetData ) ;
+ }
+ return Status ;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FBO_AdjustDeviceName
+//
+// Description: Change FBO Device Name
+//
+// Input:
+//
+// Output:
+//
+// Notes: EIP 143657
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+FBO_AdjustDeviceName()
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ FBO_DEVICE_INFORM *Node = NULL, *PreNode = NULL ;
+ UINT16 x ;
+ GetDevInformByBootOptionList(&Node) ;
+ for ( x=0 ; FboChangeDeviceNameFuncs[x] ; x++)
+ FboChangeDeviceNameFuncs[x](Node) ;
+
+ // Free Linked list data ;
+ while (Node)
+ {
+ PreNode = Node;
+ Node = Node->Next;
+ pBS->FreePool(PreNode);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_SetBootOptionTags
+//
+// Description: Go through the entire boot option list and Apply priorities for
+// each entry in the list.
+//
+// Input: DLIST *BootOptionList - the entire Boot Option List
+//
+// Output: none
+//
+// Note: To change boot order priorities
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FBO_SetBootOptionTags(){
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ UINT32 UefiBootOptionsInc = 0x100;
+
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ UINT32 TagPriority;
+ UINT32 BaseTag = UNASSIGNED_HIGHEST_TAG;
+#ifdef CSM_SUPPORT
+ if (IsLegacyBootOption(Option)){
+ UINT16 DeviceType;
+ DeviceType = ((BBS_BBS_DEVICE_PATH*)Option->FilePathList)->DeviceType;
+ if( DeviceType == BoTagLegacyBevDevice )
+ BaseTag = DeviceType;
+ else
+ if( DeviceType != BBS_UNKNOWN )
+ BaseTag = FixedLegacyBootOptionTags[DeviceType];
+ }else
+#endif
+ if (IsShellBootOption(Option)) BaseTag = BoTagEmbeddedShell;
+ else BaseTag = BoTagUefi;
+ if (BaseTag == UNASSIGNED_HIGHEST_TAG) continue;
+ TagPriority = FBO_FindTagPriority(BaseTag);
+ //UEFI boot options must have unique tags, otherwise then will be groupped when
+ //GROUP_BOOT_OPTIONS_BY_TAG tokens is enabled
+ if (BaseTag == BoTagUefi) BaseTag += UefiBootOptionsInc++;
+ Option->Tag = BootOptionTag(BaseTag, TagPriority);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetUefiBootOptionTag
+//
+// Description: Function returns device type for given handle
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *Dp -
+//
+// Output: UINT32 - device type
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 GetUefiBootOptionTag(
+ IN EFI_DEVICE_PATH_PROTOCOL *Dp
+)
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle, BlockHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DpPtr = Dp;
+ BOOLEAN IsUSB = FALSE;
+
+ if( Dp == NULL )
+ return UNASSIGNED_HIGHEST_TAG;
+
+ for( ; !(isEndNode(DpPtr)); DpPtr = NEXT_NODE(DpPtr))
+ {
+ if(DpPtr->Type == MESSAGING_DEVICE_PATH)
+ {
+ if(DpPtr->SubType == MSG_USB_DP)
+ IsUSB = TRUE;
+ //Check Windows To Go USB Hard Disk boot option. (EIP101213+)>
+ if(DpPtr->SubType == MSG_USB_CLASS_DP)
+ return BoTagUefiUsbHardDisk;
+ else //<(EIP101213+)
+ if(DpPtr->SubType == MSG_MAC_ADDR_DP)
+ return BoTagUefiNetWork;
+ else
+ if( (DpPtr->SubType == MSG_IPv4_DP) || (DpPtr->SubType == MSG_IPv6_DP) )
+ return BoTagUefiNetWork;
+
+ continue;
+ }
+
+ if(DpPtr->Type == MEDIA_DEVICE_PATH)
+ {
+ if(!IsUSB && DpPtr->SubType == MEDIA_HARDDRIVE_DP)
+ return BoTagUefiHardDisk;
+ else
+ if(!IsUSB && DpPtr->SubType == MEDIA_CDROM_DP)
+ return BoTagUefiCdrom;
+ else
+ if(IsUSB && DpPtr->SubType == MEDIA_HARDDRIVE_DP)
+ {
+ Status=pBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &Dp, &Handle);
+ if(!EFI_ERROR(Status))
+ {
+ BlockHandle = GetPhysicalBlockIoHandle(Handle);
+ if( IsUSBkeyByHandle( BlockHandle ) )
+ return BoTagUefiUsbKey;
+ else
+ return BoTagUefiUsbHardDisk;
+ }
+ }
+ else
+ if(IsUSB && DpPtr->SubType == MEDIA_CDROM_DP)
+ return BoTagUefiUsbCdrom;
+ }
+ }
+ //(EIP96232+)>
+
+ if( IsUSB )
+ {
+ Status=pBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &Dp, &Handle);
+ if(!EFI_ERROR(Status))
+ {
+ EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID;
+ EFI_BLOCK_IO_PROTOCOL *BlkIo;
+
+ BlockHandle = GetPhysicalBlockIoHandle(Handle);
+
+ if ( !EFI_ERROR( pBS->HandleProtocol(
+ BlockHandle,
+ &gEfiBlockIoProtocolGuid,
+ &BlkIo)))
+ {
+ return BoTagUefiUSBFloppy;
+ }
+ }
+ }
+ //<(EIP96232+)
+ return BoTagUefi;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.cif b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.cif
new file mode 100644
index 0000000..f01e792
--- /dev/null
+++ b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "Default FixedBootOrder"
+ category = ModulePart
+ LocalRoot = "Board\EM\FixedBootOrder\DefaultFixedBootOrder\"
+ RefName = "DefaultFixedBootOrder"
+[files]
+"DefaultFixedBootOrder.sdl"
+"DefaultFixedBootOrder.c"
+"DefaultFixedBootOrder.sd"
+"DefaultFixedBootOrder.uni"
+"DefaultFixedBootOrder.mak"
+<endComponent>
diff --git a/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.mak b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.mak
new file mode 100644
index 0000000..b84c020
--- /dev/null
+++ b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.mak
@@ -0,0 +1,107 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2012, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+#**********************************************************************
+# $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/DefaultFixedBootOrder.mak $
+#
+# $Author: Walonli $
+#
+# $Revision: 2 $
+#
+# $Date: 8/13/14 11:20p $
+#
+#*****************************************************************
+#*****************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/DefaultFixedBootOrder.mak $
+#
+# 2 8/13/14 11:20p Walonli
+# [TAG] EIP180632
+# [Category] New Feature
+# [Description] Add FixedBootOrder Protocol to change device/group
+# name.
+# [Files] DefaultFixedBootOrder.sdl
+# DefaultFixedBootOrder.c
+# DefaultFixedBootOrder.mak
+# DefaultFixedBootOrder.cif
+#
+# 1 6/28/12 11:41a Easonchen
+# Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+# functionality.
+#
+#
+#*****************************************************************
+
+
+# MAK file for the eModule:DefaultFixedBootOrder
+
+#<AMI_FHDR_START>
+#-----------------------------------------------------------------------
+# Name: DefaultFixedBootOrder.mak
+#
+# Description: This is a make file used to build component
+#
+#-----------------------------------------------------------------------
+#<AMI_FHDR_END>
+all : DefaultFixedBootOrder
+
+CORE_DXE_LIBBin : $(BUILD_DIR)\DefaultFixedBootOrder.obj
+
+DefaultFixedBootOrder : $(BUILD_DIR)\DefaultFixedBootOrder.mak
+
+#-----------------------------------------------------------------------
+# Generic dependencies
+#-----------------------------------------------------------------------
+$(BUILD_DIR)\DefaultFixedBootOrder.mak : $(DefaultFixedBootOrder_DIR)\$(@B).cif $(DefaultFixedBootOrder_DIR)\$(@B).mak DefaultFixedBootOrderElink $(BUILD_RULES)
+ $(CIF2MAK) $(DefaultFixedBootOrder_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+#-----------------------------------------------------------------------
+# Paths and other definitions
+#-----------------------------------------------------------------------
+
+#-----------------------------------------------------------------------
+# AMICSP library files compilation
+#-----------------------------------------------------------------------
+{$(DefaultFixedBootOrder_DIR)}.c{$(BUILD_DIR)}.obj::
+ $(CC) $(CFLAGS) /I $(INCLUDE_DIR) /I $(TSEBIN_DIR)\inc /I $(FixedBootOrder_DIR) /I $(DefaultFixedBootOrder_DIR) /I $(Foundation_DIR) /I $(CORE_DXE_DIR) /Fo$(BUILD_DIR)\ $<
+
+#-----------------------------------------------------------------------
+# Create OEM Boot Order Setup Screens
+#-----------------------------------------------------------------------
+SetupSdbs : $(BUILD_DIR)\DefaultFixedBootOrder.mak DefaultFixedBootOrderSDB
+
+DefaultFixedBootOrderSDB :
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\DefaultFixedBootOrder.mak all\
+ TYPE=SDB NAME=DefaultFixedBootOrder MAKEFILE=$(BUILD_DIR)\DefaultFixedBootOrder.mak STRING_CONSUMERS=$(DefaultFixedBootOrder_DIR)\DefaultFixedBootOrder.sd
+
+DefaultFixedBootOrderElink :
+ $(SILENT)type << >$(BUILD_DIR)\DefaultFixedBootOrder.h
+#define FBO_CHANGE_DEVICE_NAME_FUNCS $(FBO_ChangeDeviceNameFunctions)$(EOL)
+<<
+
+#-----------------------------------------------------------------------
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2012, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sd b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sd
new file mode 100644
index 0000000..97811b7
--- /dev/null
+++ b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sd
@@ -0,0 +1,962 @@
+#include <token.h>
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+#define Device1 0
+#define Device2 1
+#define Device3 2
+#define Device4 3
+#define Device5 4
+#define Device6 5
+#define Device7 6
+#define Device8 7
+#define Device9 8
+#define Device10 9
+#define Device11 10
+#define Device12 11
+#define Device13 12
+#define Device14 13
+#define Device15 14
+#else
+#define Device1 1
+#define Device2 2
+#define Device3 3
+#define Device4 4
+#define Device5 5
+#define Device6 6
+#define Device7 7
+#define Device8 8
+#define Device9 8
+#define Device10 9
+#define Device11 10
+#define Device12 11
+#define Device13 12
+#define Device14 13
+#endif
+
+#ifdef SETUP_DATA_DEFINITION
+/***********************************************************/
+/* Put NVRAM data definitions here.
+/* For example: UINT8 Data1;
+/* These definitions will be converted by the build process
+/* to a definitions of SETUP_DATA fields.
+/***********************************************************/
+UINT16 LegacyPriorities[16];
+UINT16 UefiPriorities[16];
+#if FBO_DUAL_MODE
+UINT16 DualPriorities[32];
+#endif
+UINT8 FBO_Init;
+UINT8 BootMode;
+#if USE_BCP_DEFAULT_PRIORITIES
+//UINT16 BcpDefaultPriorities[8];
+UINT16 BcpDefaultLegacyPriorities[8]; //(EIP115686+)
+UINT16 BcpDefaultUefiPriorities[8]; //(EIP115686+)
+#if FBO_DUAL_MODE
+UINT16 BcpDefaultDualPriorities[32];
+#endif
+#endif
+
+#endif
+
+
+#if 0
+STRING_TOKEN(STR_BOOT_OPTION)
+STRING_TOKEN(STR_BOOT_OPTION_HELP)
+STRING_TOKEN(STR_BOOT_HDD)
+STRING_TOKEN(STR_BOOT_CDROM)
+STRING_TOKEN(STR_BOOT_NETWORK)
+STRING_TOKEN(STR_BOOT_USBHDD)
+STRING_TOKEN(STR_BOOT_USBODD)
+STRING_TOKEN(STR_BOOT_USBFDD)
+STRING_TOKEN(STR_BOOT_USBKEY)
+
+STRING_TOKEN(STR_BOOT_UEFI_HDD)
+STRING_TOKEN(STR_BOOT_UEFI_CDROM)
+STRING_TOKEN(STR_BOOT_UEFI_NETWORK)
+STRING_TOKEN(STR_BOOT_UEFI_USBHDD)
+STRING_TOKEN(STR_BOOT_UEFI_USBODD)
+STRING_TOKEN(STR_BOOT_UEFI_USBFDD)
+STRING_TOKEN(STR_BOOT_UEFI_USBKEY)
+
+STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD)
+STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM)
+STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK)
+STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD)
+STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD)
+STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD)
+STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY)
+
+STRING_TOKEN(STR_BOOT_ORDER_1)
+STRING_TOKEN(STR_BOOT_ORDER_2)
+STRING_TOKEN(STR_BOOT_ORDER_3)
+STRING_TOKEN(STR_BOOT_ORDER_4)
+STRING_TOKEN(STR_BOOT_ORDER_5)
+STRING_TOKEN(STR_BOOT_ORDER_6)
+STRING_TOKEN(STR_BOOT_ORDER_7)
+STRING_TOKEN(STR_BOOT_ORDER_8)
+STRING_TOKEN(STR_BOOT_ORDER_9)
+STRING_TOKEN(STR_BOOT_ORDER_10)
+STRING_TOKEN(STR_BOOT_ORDER_11)
+STRING_TOKEN(STR_BOOT_ORDER_12)
+STRING_TOKEN(STR_BOOT_ORDER_13)
+STRING_TOKEN(STR_BOOT_ORDER_14)
+STRING_TOKEN(STR_BOOT_ORDER_15)
+STRING_TOKEN(STR_BOOT_ORDER_16)
+#endif
+
+#ifdef BOOT_FORM_SET
+
+ #ifdef FORM_SET_TYPEDEF
+ #include "Board\EM\FixedBootOrder\FixedBootOrder.h"
+ #endif
+
+ #ifdef FORM_SET_VARSTORE
+ varstore FIXED_BOOT_SETUP,
+ key = AUTO_ID(FIXED_BOOT_KEY),
+ name = FixedBoot,
+ guid = SETUP_GUID;
+
+ varstore FIXED_BOOT_GROUP,
+ key = AUTO_ID(FIXED_BOOT_KEY1),
+ name = FixedBootGroup,
+ guid = SETUP_GUID;
+ #endif
+
+ #ifdef FORM_SET_ITEM
+
+ //----------------------------------------
+ //Set default FBO_Init = 0, don't display.
+ suppressif ideqvallist SETUP_DATA.FBO_Init == 0 1;
+ checkbox varid = SETUP_DATA.FBO_Init,
+ prompt = STRING_TOKEN(STR_EMPTY),
+ help = STRING_TOKEN(STR_EMPTY),
+ flags = 0, // Flags behavior for checkbox is overloaded so that it equals a DEFAULT value.
+ endcheckbox;
+ endif;
+ //----------------------------------------
+ //Make default to variable "StdDefault",don't display.
+ suppressif ideqvallist SETUP_DATA.FBO_Init == 0 1;
+ oneof varid = FIXED_BOOT_SETUP.LegacyDevice[0],
+ prompt = STRING_TOKEN(STR_EMPTY),
+ help = STRING_TOKEN(STR_EMPTY),
+ option text = STRING_TOKEN(STR_EMPTY), value = 0, flags = DEFAULT;
+ option text = STRING_TOKEN(STR_EMPTY), value = 1, flags = 0;
+ endoneof;
+ endif;
+ suppressif ideqvallist SETUP_DATA.FBO_Init == 0 1;
+ oneof varid = FIXED_BOOT_GROUP.LegacyHDD,
+ prompt = STRING_TOKEN(STR_EMPTY),
+ help = STRING_TOKEN(STR_EMPTY),
+ option text = STRING_TOKEN(STR_EMPTY), value = 0, flags = DEFAULT;
+ option text = STRING_TOKEN(STR_EMPTY), value = 1, flags = 0;
+ endoneof;
+ endif;
+ //----------------------------------------
+#if CSM_SUPPORT
+ oneof varid = SETUP_DATA.BootMode,
+ prompt = STRING_TOKEN(STR_BOOT_MODE_SEL),
+ help = STRING_TOKEN(STR_BOOT_MODE_SEL_HELP),
+ option text = STRING_TOKEN(STR_BOOT_MODE_LEGACY), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
+ option text = STRING_TOKEN(STR_BOOT_MODE_UEFI), value = 1, flags = 0;
+#if FBO_DUAL_MODE
+ option text = STRING_TOKEN(STR_BOOT_MODE_DUAL), value = 2, flags = 0;
+#endif
+ endoneof;
+#else
+ //No Legacy device,Set default is UEFI mode, don't display this.
+ suppressif ideqvallist SETUP_DATA.FBO_Init == 0 1;
+ oneof varid = SETUP_DATA.BootMode,
+ prompt = STRING_TOKEN(STR_BOOT_MODE_SEL),
+ help = STRING_TOKEN(STR_BOOT_MODE_SEL_HELP),
+ option text = STRING_TOKEN(STR_BOOT_MODE_LEGACY), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_MODE_UEFI), value = 1, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
+#if FBO_DUAL_MODE
+ option text = STRING_TOKEN(STR_BOOT_MODE_DUAL), value = 2, flags = 0;
+#endif
+ endoneof;
+ endif;
+#endif //#if CSM_SUPPORT
+
+ SEPARATOR
+ SUBTITLE(STRING_TOKEN(STR_FIXED_BOOT_ORDER_SUBTITLE))
+
+ //LEGACY BOOT ITEM
+ suppressif ideqvallist SETUP_DATA.BootMode == 1 2;
+ label AUTO_ID(FIXED_BOOT_ITEM_LABEL1);
+ endif; //suppressif
+
+ //UEFI BOOT ITEM
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 2;
+ label AUTO_ID(FIXED_BOOT_ITEM_LABEL2);
+ endif; //suppressif
+#if FBO_DUAL_MODE
+ //LEGACY/UEFI BOOT ITEM
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1;
+ label AUTO_ID(FIXED_BOOT_ITEM_LABEL3);
+ endif; //suppressif
+#endif
+ //(EIP107268+)>
+#if USE_BCP_DEFAULT_PRIORITIES
+ //----------------------------------------------------------------------------------//
+ // USE for AMIBCP tool BcpDefaultUefiPriorities[Device1] - [Device7] //
+ // //
+ // NOT DISPLAY //
+ // //
+ // The value sequence need same with FBOUefiDevMapData[] //
+ //----------------------------------------------------------------------------------//
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+
+ SEPARATOR
+ SUBTITLE(STRING_TOKEN(STR_BCP_UEFI_DEFAULT_SUBTITLE))
+
+ oneof varid = SETUP_DATA.BcpDefaultUefiPriorities[Device1],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_1),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultUefiPriorities[Device2],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_2),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultUefiPriorities[Device3],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_3),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultUefiPriorities[Device4],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_4),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0; //<(EIP115686+)
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultUefiPriorities[Device5],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_5),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultUefiPriorities[Device6],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_6),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultUefiPriorities[Device7],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_7),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = MANUFACTURING | DEFAULT;
+ endoneof;
+ endif; //suppressif
+
+ //----------------------------------------------------------------------------------//
+ // USE for AMIBCP tool BcpDefaultPriorities[Device1] - [Device7] //
+ // //
+ // NOT DISPLAY //
+ // //
+ // The value sequence need same with FBOLegacyDevMapData[] //
+ //----------------------------------------------------------------------------------//
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+
+ SEPARATOR
+ SUBTITLE(STRING_TOKEN(STR_BCP_DEFAULT_SUBTITLE))
+
+ oneof varid = SETUP_DATA.BcpDefaultLegacyPriorities[Device1],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_1),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultLegacyPriorities[Device2],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_2),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultLegacyPriorities[Device3],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_3),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultLegacyPriorities[Device4],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_4),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultLegacyPriorities[Device5],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_5),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultLegacyPriorities[Device6],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_6),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultLegacyPriorities[Device7],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_7),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK),value = 6, flags = MANUFACTURING | DEFAULT;
+ endoneof;
+ endif; //suppressif
+
+ //(EIP122146+)>
+#if FBO_DUAL_MODE
+ //----------------------------------------------------------------------------------//
+ // USE for AMIBCP tool BcpDefaultDualPriorities[Device1] - [Device_x] //
+ // //
+ // NOT DISPLAY //
+ // //
+ // The value sequence need same with FBODualDevMapData[] //
+ //----------------------------------------------------------------------------------//
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+
+ SEPARATOR
+ SUBTITLE(STRING_TOKEN(STR_BCP_DUAL_DEFAULT_SUBTITLE))
+
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device1],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_1),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device2],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_2),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device3],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_3),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device4],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_4),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device5],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_5),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device6],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_6),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device7],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_7),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device8],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_8),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device9],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_9),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device10],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_10),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device11],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_11),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device12],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_12),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device13],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_13),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = MANUFACTURING | DEFAULT;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = 0;
+ endoneof;
+ endif; //suppressif
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0 1 2 3 4 5;
+ oneof varid = SETUP_DATA.BcpDefaultDualPriorities[Device14],
+ prompt = STRING_TOKEN(STR_BOOT_ORDER_14),
+ help = STRING_TOKEN(STR_BOOT_OPTION_HELP),
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_HDD), value = 0, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_CDROM), value = 1, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBHDD), value = 2, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBODD), value = 3, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBKEY), value = 4, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_USBFDD), value = 5, flags = 0;
+ option text = STRING_TOKEN(STR_DUAL_BOOT_UEFI_NETWORK),value = 6, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_HDD), value = 7, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_CDROM), value = 8, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBHDD), value = 9, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBODD), value = 10, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBKEY), value = 11, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_USBFDD), value = 12, flags = 0;
+ option text = STRING_TOKEN(STR_BOOT_NETWORK), value = 13, flags = MANUFACTURING | DEFAULT;
+ endoneof;
+ endif; //suppressif
+
+#endif //#if FBO_DUAL_MODE
+ //<(EIP122146+)
+#endif //#if USE_BCP_DEFAULT_PRIORITIES
+ //<(EIP107268+)
+ #endif //FORM_SET_ITEM
+
+
+ #ifdef FORM_SET_GOTO
+ //
+ // Define goto commands for the forms defined in this file
+ //
+ SEPARATOR
+#if CSM_SUPPORT
+ //--------------------------------------------------
+ // LEGACY GROUP FORM GOTO ITEM
+ //--------------------------------------------------
+ suppressif ideqvallist SETUP_DATA.BootMode == 1;
+ suppressif ideqvallist FIXED_BOOT_GROUP.LegacyHDD == 0;
+ goto HDD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_HDD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_HDD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 1;
+ suppressif ideqvallist FIXED_BOOT_GROUP.LegacyODD == 0;
+ goto ODD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_ODD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_ODD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 1;
+ suppressif ideqvallist FIXED_BOOT_GROUP.LegacyNET == 0;
+ goto NET_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_NET_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_NET_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 1;
+ suppressif ideqvallist FIXED_BOOT_GROUP.LegacyUSBHDD == 0;
+ goto USBHDD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_USBHDD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_USBHDD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 1;
+ suppressif ideqvallist FIXED_BOOT_GROUP.LegacyUSBKEY == 0;
+ goto USBKEY_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_USBKEY_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_USBKEY_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 1;
+ suppressif ideqvallist FIXED_BOOT_GROUP.LegacyUSBODD == 0;
+ goto USBODD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_USBODD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_USBODD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 1;
+ suppressif ideqvallist FIXED_BOOT_GROUP.LegacyUSBFDD == 0;
+ goto USBFDD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_USBFDD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_USBFDD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+#endif
+ //--------------------------------------------------
+ // UEFI GROUP FORM GOTO ITEM
+ //--------------------------------------------------
+ suppressif ideqvallist SETUP_DATA.BootMode == 0;
+ suppressif ideqvallist FIXED_BOOT_GROUP.UefiHDD == 0;
+ goto UEFI_HDD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_UEFI_HDD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_UEFI_HDD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0;
+ suppressif ideqvallist FIXED_BOOT_GROUP.UefiODD == 0;
+ goto UEFI_ODD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_UEFI_ODD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_UEFI_ODD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0;
+ suppressif ideqvallist FIXED_BOOT_GROUP.UefiNET == 0;
+ goto UEFI_NET_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_UEFI_NET_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_UEFI_NET_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0;
+ suppressif ideqvallist FIXED_BOOT_GROUP.UefiUSBHDD == 0;
+ goto UEFI_USBHDD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_UEFI_USBHDD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_UEFI_USBHDD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0;
+ suppressif ideqvallist FIXED_BOOT_GROUP.UefiUSBODD == 0;
+ goto UEFI_USBODD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_UEFI_USBODD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_UEFI_USBODD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0;
+ suppressif ideqvallist FIXED_BOOT_GROUP.UefiUSBKEY == 0;
+ goto UEFI_USBKEY_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_UEFI_USBKEY_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_UEFI_USBKEY_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ suppressif ideqvallist SETUP_DATA.BootMode == 0;
+ suppressif ideqvallist FIXED_BOOT_GROUP.UefiUSBFDD == 0;
+ goto UEFI_USBFDD_BOOT_FORM_ID,
+ prompt = STRING_TOKEN(STR_UEFI_USBFDD_BOOT_ORDER_SUBTITLE),
+ help = STRING_TOKEN(STR_UEFI_USBFDD_BOOT_ORDER_HELP);
+ endif;
+ endif;
+
+ #endif //#ifdef FORM_SET_GOTO
+
+
+ #ifdef FORM_SET_FORM
+
+ //
+ // Define all device group forms in this file
+ //
+#if CSM_SUPPORT
+ //--------------------------------------------------
+ // LEGACY GROUP FORM ITEM
+ //--------------------------------------------------
+ //HDD GROUP FORM
+ form formid = AUTO_ID(HDD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_HDD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(HDD_BOOT_FORM_LABEL);
+ endform;
+
+ //ODD GROUP FORM
+ form formid = AUTO_ID(ODD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_ODD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(ODD_BOOT_FORM_LABEL);
+ endform;
+
+ //NETWORK GROUP FORM
+ form formid = AUTO_ID(NET_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_NET_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(NET_BOOT_FORM_LABEL);
+ endform;
+
+ //USBHDD GROUP FORM
+ form formid = AUTO_ID(USBHDD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_USBHDD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(USBHDD_BOOT_FORM_LABEL);
+ endform;
+
+ //USBKEY GROUP FORM
+ form formid = AUTO_ID(USBKEY_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_USBKEY_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(USBKEY_BOOT_FORM_LABEL);
+ endform;
+
+ //USBODD GROUP FORM
+ form formid = AUTO_ID(USBODD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_USBODD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(USBODD_BOOT_FORM_LABEL);
+ endform;
+
+ //USBFDD GROUP FORM
+ form formid = AUTO_ID(USBFDD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_USBFDD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(USBFDD_BOOT_FORM_LABEL);
+ endform;
+#endif
+ //--------------------------------------------------
+ // UEFI GROUP FORM ITEM
+ //--------------------------------------------------
+
+ //UEFI HDD GROUP FORM
+ form formid = AUTO_ID(UEFI_HDD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_UEFI_HDD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(UEFI_HDD_BOOT_FORM_LABEL);
+ endform;
+
+ //UEFI ODD GROUP FORM
+ form formid = AUTO_ID(UEFI_ODD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_UEFI_ODD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(UEFI_ODD_BOOT_FORM_LABEL);
+ endform;
+
+ //UEFI NETWORK GROUP FORM
+ form formid = AUTO_ID(UEFI_NET_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_UEFI_NET_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(UEFI_NET_BOOT_FORM_LABEL);
+ endform;
+
+ //UEFI USBHDD GROUP FORM
+ form formid = AUTO_ID(UEFI_USBHDD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_UEFI_USBHDD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(UEFI_USBHDD_BOOT_FORM_LABEL);
+ endform;
+
+ //UEFI USBODD GROUP FORM
+ form formid = AUTO_ID(UEFI_USBODD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_UEFI_USBODD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(UEFI_USBODD_BOOT_FORM_LABEL);
+ endform;
+
+ //UEFI USBKEY GROUP FORM
+ form formid = AUTO_ID(UEFI_USBKEY_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_UEFI_USBKEY_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(UEFI_USBKEY_BOOT_FORM_LABEL);
+ endform;
+
+ //UEFI USBFDD GROUP FORM
+ form formid = AUTO_ID(UEFI_USBFDD_BOOT_FORM_ID),
+ title = STRING_TOKEN(STR_UEFI_USBFDD_BOOT_ORDER_SUBTITLE);
+ label AUTO_ID(UEFI_USBFDD_BOOT_FORM_LABEL);
+ endform;
+ #endif //#ifdef FORM_SET_FORM
+
+#endif //#ifdef BOOT_FORM_SET
diff --git a/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sdl b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sdl
new file mode 100644
index 0000000..e06ca1b
--- /dev/null
+++ b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sdl
@@ -0,0 +1,88 @@
+TOKEN
+ Name = "DEFAULT_FIXED_BOOT_ORDER_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable module part support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "FBO_STRING_INIT_FORM_SET_CLASS"
+ Value = "BOOT_FORM_SET_CLASS"
+ Help = "Define winch FORM_SET of InitString."
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FBO_VFR_FORM_ID"
+ Value = "BOOT_MAIN"
+ Help = "Define winch FORM ID of vfr."
+ TokenType = Expression
+ TargetH = Yes
+End
+
+PATH
+ Name = "DefaultFixedBootOrder_DIR"
+ Path = "Board\EM\FixedBootOrder\DefaultFixedBootOrder"
+End
+
+MODULE
+ Help = "Includes DefaultFixedBootOrder.mak to Project"
+ File = "DefaultFixedBootOrder.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\DefaultFixedBootOrder.SDB"
+ Parent = "SETUP_SDBS"
+ Priority = 40
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(DefaultFixedBootOrder_DIR)\DefaultFixedBootOrder.sd"
+ Parent = "SETUP_DEFINITIONS"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "DefaultFixedBootOrder_Init,"
+ Parent = "UpdateBootOptionVariables,"
+ InvokeOrder = BeforeParent
+End
+
+ELINK
+ Name = "FBO_SetBootOptionTags,"
+ Parent = "SetBootOptionTags,"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "FBO_AdjustDeviceName,"
+ Parent = "SaveBootOptions,"
+ InvokeOrder = BeforeParent
+End
+
+ELINK
+ Name = "FBO_ChangeDeviceNameFunctions"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "ITEM_CALLBACK(BOOT_FORM_SET_CLASS,0,0x1001,FixedBootOrderFormCallBack),"
+ Parent = "SetupItemCallbacks"
+ Token = "EFI_SPECIFICATION_VERSION" ">" "0x20000"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "DefaultFixedBootOrder_Init,"
+ Parent = "BeforeConnectFastBootDeviceHook"
+ Token = "FAST_BOOT_SUPPORT" "=" "1"
+ Token = "CORE_COMBINED_VERSION" ">" "0x40280"
+ Priority = 1
+ InvokeOrder = BeforeParent
+End
diff --git a/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.uni b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.uni
new file mode 100644
index 0000000..fce2fde
--- /dev/null
+++ b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.uni
Binary files differ
diff --git a/Board/EM/FixedBootOrder/FBOSetOrder.c b/Board/EM/FixedBootOrder/FBOSetOrder.c
new file mode 100644
index 0000000..35d7b11
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FBOSetOrder.c
@@ -0,0 +1,1699 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FBOSetOrder.c $
+//
+// $Author: Walonli $
+//
+// $Revision: 31 $
+//
+// $Date: 3/26/15 10:50p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FBOSetOrder.c $
+//
+// 31 3/26/15 10:50p Walonli
+// [TAG] EIP210628
+// [Category] Improvement
+// [Description] Fixed build error when USE_BCP_DEFAULT_PRIORITIES token
+// enable.
+// [Files] Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// FixedBootOrder.cif
+//
+// 30 5/20/14 3:48a Klzhan
+// [TAG] EIP167196
+// [Category] Improvement
+// [Description] Runtime attribute set for the some of the variable used
+// by FixedBootOrder needs to be reviewed.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 29 4/16/14 5:16a Walonli
+//
+// 28 4/15/14 2:26a Klzhan
+// [TAG] EIP143078
+// [Category] Improvement
+// [Description] Set LOAD_OPTION_ACTIVE must be 0 when
+// LOAD_OPTION_HIDDEN=1
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 27 12/05/13 1:00a Klzhan
+// [TAG] EIP143740
+// [Category] Improvement
+// [Description] 1. Add a token for setting Windows To Go boot option to
+// 1st priority.
+// 2. Clean up code for windows to go
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// FixedBootOrder.cif
+//
+// 26 10/21/13 5:41a Easonchen
+// [TAG] EIP129692
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BBS Priorities become DISABLE when set ENABLE in Boot
+// Option Priorities
+// [RootCause] Variable "UefiDevOrder" not set "Disable" Mask.
+// [Solution] Add "Disable" mask to variable "UefiDevOrder"
+// [Files] FboSetOrder.c
+// FixedBootOrderTse.c
+//
+// 25 8/12/13 11:24p Easonchen
+// [TAG] EIP128779
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] UEFI USB CD/DVD Drive BBS Priotites displayed incorrectly
+// [RootCause] Boot#### Boot Option record disable status. when group
+// set to disable, group sub-menu display too.
+// [Solution] Not change Boot#### disable status, Use variable
+// "UefiDevOrder" record boot option disable status.
+// [Files] FBOSetOrder.c
+//
+// 24 8/12/13 4:17a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] CppCheck error fix.
+// [Files] FBOSetOrder.c
+//
+// 23 5/28/13 5:25a Easonchen
+// [TAG] EIP122146
+// [Category] Improvement
+// [Description] Support Dual mode default priority with tool AMIBCP.
+// [Files]
+// FboSetOrder.c
+// FixedBootOrder.c
+// FixedBoorOrderTse.c
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 22 4/22/13 11:04p Easonchen
+// [TAG] EIP101213
+// [Category] Improvement
+// [Description] FixedBootOrder should match the BootOrder variable
+// [Files] FboSetOrder.c
+// FixedBootOrder.sdl
+//
+// 21 4/09/13 9:07a Easonchen
+// [TAG] EIP118170
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Windows Boot Manager will become disable on BBS Priorities
+// when change Boot option filter
+// [RootCause] when CsmOptOut module set legacy only, windows boot
+// mangger boot option attribute become LOAD_OPTION_HIDDEN.
+// [Solution] Check boot option attribute LOAD_OPTION_HIDDEN then don't
+// disable boot option.
+// [Files] FboSetOrder.c
+//
+// 20 2/19/13 1:49a Easonchen
+// [TAG] EIP114186
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BSU Exit Page, Boot Override appears ¡§Unknown Device¡¨
+// [RootCause] same boot option priority.
+// [Solution] reassign boot option priority.
+// [Files] FboSetOrder.c
+//
+// 19 2/05/13 3:46a Easonchen
+// [TAG] EIP107268
+// [Category] New Feature
+// [Description] Add support managing default boot order list using
+// AMIBCP.
+// [Files]
+// FBOSetOrder.c
+// FixedBootOrder.c
+// FixedBootOrderTSE.c
+// FixedBootOrder.sdl
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 18 12/07/12 2:03a Easonchen
+// [TAG] EIP107440
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] In UEFI mode, system should be only boot with EFI boot
+// device.However, system will boot into DOS when enter "exit" in EFI
+// shell.
+// [RootCause] BootOption LOAD_OPTION_ACTIVE not setting.
+// [Solution] Add BootOption LOAD_OPTION_ACTIVE set disable in UEFI
+// mode.
+//
+// 17 11/09/12 4:56a Easonchen
+// [TAG] EIP99368
+// [Category] Improvement
+// [Description] WHCK - Boot from USB
+// [Files] FBOSetOrder.c
+//
+// 16 9/20/12 2:45a Easonchen
+// [TAG] EIP100223
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] does not recognize a USB device correctly.
+// [RootCause] First plug USB CDROM boot option number is 0003, unplug
+// and plug USB HDD boot option number is 0003 again.
+// [Solution] Add device type check to filter.
+// [Files] FBOSetOrder.c
+//
+// 15 6/28/12 11:22a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+// functionality.
+//
+// 14 6/11/12 10:04a Easonchen
+// [TAG] EIP92141
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] build error with TSE 1227
+// [RootCause] TSE EDKhelper.c change function name DivU64x32 to
+// AmiTseDivU64x32.
+// [Solution] Change to use function Div64
+// [Files] FBOSetOrder.c
+//
+// 12 5/02/12 2:49a Easonchen
+// [TAG] EIP87316
+// [Category] Improvement
+// [Description] FixedBootOrder Module needs support CsmOptOut Boot
+// Filter UEFI Only. Set BBS Table BootPriority to BBS_IGNORE_ENTRY.
+// [Files] FBOSetOrder.c
+//
+// 11 6/17/11 3:44a Easonchen
+// [TAG] EIP57950
+// [Category] Improvement
+// [Description]
+// Replace BBS_TABLE BootPriority BBS_UNPRIORITIZED_ENTRY to
+// BBS_DO_NOT_BOOT_FROM.
+//
+// 10 4/14/11 4:01a Easonchen
+// TAG: EIP35562
+// In Core 4.6.4.1 or Last, Fixed boot variable name - hex digits should
+// be in upper case
+//
+// TAG: EIP54209
+// Improvement: NetBootHotKey eModule Functionality with TSE 1210
+// Verification Check
+// [Description]
+// Check TSE gBootFlow status in function FBOCheckNormalBoot
+//
+// TAG: EIP57727
+// Improvement: It always increase one device while reboot in F12 (Boot
+// device menu) even you only insert one HDD in it.
+// [Description]
+// Modify function UpdateBootOrder() and AddUEFIDevice() to support
+// 4.6.4.1
+//
+// 9 3/31/11 2:03a Easonchen
+// [TAG] EIP57272
+// [Category] Improvement
+// [Description] Check BootMode BOOT_ON_S4_RESUME and exit
+// [Files] FBOSetOrder.c
+//
+// 8 3/22/11 4:35a Easonchen
+// [TAG] EIP51709
+// [Category] Improvement
+// [Description] 1.Code is reformatted in accordance with the coding
+// standards.
+// 2.Remove file boot.vfr and setup.c, OEM need patch boot.vfr to remove
+// original boot options.
+//
+// 7 12/10/10 4:41a Easonchen
+// Minor bug fix (EIP47257.2)
+//
+// 6 11/12/10 2:57a Easonchen
+// Add TSE ELINK ProcessProceedToBootNowHook.
+//
+// TAG: EIP33514
+// Improvement: The FixedBootOrder function caused the side effect
+// -"AMT_TC010( IDE-Redirection).
+// [Description]
+// Check variable "AmtBootOption" created, OemFixedBootOrder() don't
+// change BBS_TABE Boot priority.
+//
+// TAG: EIP47257
+// Improvement: Load Default user define HDD order will lost.
+// [Description]
+// Modified routine BbsChecksum(), If can't get hard disk serial number.
+// use device name to make checksum.
+//
+// 5 9/14/10 3:04a Easonchen
+// TAG: EIP33514
+// Improvement: Modify function FixedBootOrderSaveChange().
+// [Description]
+// 1.Change BOOT#### LoadOption Bit Active status.
+// 2.Update variable BootOrder after SaveChange.
+// TAG: EIP33900
+// Improvement: add function FixedBootOrderLoadedConfigDefaults() for TSE
+// ELINK LoadedConfigDefaults().
+// [Description]
+// 1.Add function CreateDefaultDevOrder().
+// 2.Call FixedBootOrderProtocol->load_default_string().
+// TAG: EIP30275
+// Improvement: Windows Boot Manager delete and restore.
+// [Description]
+// 1.Add function WindowsBootManager().
+// TAG: EIP26947
+// Improvement: Update variable "BootOrder" and "LegacyDevOrder"
+// [Description]
+// 1.Add function UpdateBootOrder().
+// TAG: EIP22689
+// Improvement: Support submenu function.
+//
+// 4 3/31/10 6:54a Jameswang
+// [Tag] EIP35944
+// [Bug fix] Fixed USB CDROM will be analyzed as USB key with some CD
+// medium(HD format)
+// [Severity] Medium
+// [Root cause] We only checked the USB device size to determined if it is
+// a USB key, if USB CDROM has a medium that is emulated as a HDD / Floppy
+// between 2MB and 64GB then it will also be determined as USB key.
+// [Solution] Not only checks the size but also checks BBS types for HDD
+// and Floppy, excludes CDROM.
+//
+// 3 4/15/09 6:12a Jameswang
+// TAG: EIP19998
+// Improvement: New type:BOOT_USB_KEY is added and boot option can display
+// the device name.
+// [Description]
+// 1. Added BOOT_USB_KEY type: 64GB > USB KEY!=USB floppy >= 2MB
+// 2. SetPriorityForStringInit is added for pre-running the boot order for
+// each boot options, so the FixedBootOrderStringInit can add device names
+// to strings accordingly.
+// 3. When FixedBootOrderStringInit signaling a protocol event,
+// SetPriorityForStringInit::SetPriorityForStringInit will be called and
+// gInitStrPhase=TRUE, the BBS_TABLE[].BootPriority = BOOT_XXXX enum value
+// if the device is present.
+// 4. FBORegisterEvent is linked to MinisetupDriverEntryHook and register
+// a fake protocol so FixedBootOrderStringInit can signal it and callback
+// to SetPriorityForStringInit accross the EDK.
+//
+// 2 3/26/09 2:46a Jameswang
+// All include use <> only without any path. So that include files can be
+// override by CIF2MAK "/x" option.
+// All debug message add "\n".
+//
+// 1 3/02/09 3:31a Jameswang
+// Separate OemFixedBootOrder here to be linked with minisetup because we
+// changed to use eLinks instead of using events. We will not need to
+// modify bbs.c using eLinks.
+//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------
+//
+// Name: FBOSetOrder.c
+//
+// Description: FixedBootOrder Boot Option control
+//
+//----------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+//----------------------------------------------------------------------
+// Include Files
+//----------------------------------------------------------------------
+#include <efi.h>
+#include <amidxelib.h>
+#include <protocol\blockio.h>
+
+#include <BootOptions.h>
+#include <Setup.h>
+#include <setupdata.h>
+
+#if CSM_SUPPORT
+#include <Protocol\LegacyBios.h>
+#include <protocol\LegacyBiosExt.h>
+#endif
+
+#include "FixedBootOrder.h"
+typedef CHAR8 *VA_LIST;
+#include "Core\EfiCommonLib.h"
+#include "SetupStrTokens.h"
+//---------------------------------------------------------------------------
+// Global Variable declarations
+//---------------------------------------------------------------------------
+EFI_GUID gFixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+//---------------------------------------------------------------------------
+// External functions
+//---------------------------------------------------------------------------
+EFI_HANDLE GetPhysicalBlockIoHandle(EFI_HANDLE BlockIoHandle);
+UINT32 GetUefiBootOptionTag(IN EFI_DEVICE_PATH_PROTOCOL *Dp);
+UINT16 GetDevicePortNumber(BBS_TABLE *BbsTable);
+UINT32 FindPositionInTheGroupByBbsIndex(LEGACY_DEVICE_ORDER *Group, UINT16 BbsIndex);
+//---------------------------------------------------------------------------
+// Function Definitions
+//---------------------------------------------------------------------------
+VOID BuildFboLegacyDevOrder(VOID);
+//---------------------------------------------------------------------------
+// Type definitions
+//---------------------------------------------------------------------------
+#define DEFAULTS_GUID {0x4599d26f, 0x1a11, 0x49b8, 0xb9, 0x1f, 0x85, 0x87, 0x45, 0xcf, 0xf8, 0x24}
+//---------------------------------------------------------------------------
+// Constant and Variables declarations
+//---------------------------------------------------------------------------
+FBODevMap *pFBODualDevMap = NULL;
+FBODevMap *pFBOLegacyDevMap = NULL;
+FBODevMap *pFBOUefiDevMap = NULL;
+UINT16 NewBootOptionNumber=0xffff; //(EIP101213+)
+
+UINT16 GetDevMapDataCount(FBODevMap *pFBODevMap)
+{
+ UINT16 count = 0;
+
+ if( !pFBODevMap ) return 0; //end of data
+
+ do{
+ if( pFBODevMap[count].DevType == 0 ) break;
+ count++;
+ }while(1);
+
+ return count;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SearchDevMapByType
+//
+// Description: Search DevMap data index by device type.
+//
+// Input:
+// IN FBODevMap *pFBODevMap
+// IN UINT16 DevType
+//
+// Output:
+// OUT UINT16
+//
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: None
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 SearchDevMapByType(FBODevMap *pFBODevMap, UINT16 DevType)
+{
+ UINT16 i=0;
+
+ do{
+ if(pFBODevMap[i].DevType == 0 ) break; //end of data
+ if(pFBODevMap[i].DevType == DevType)
+ return i;
+ i++;
+ }while(1);
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_FindTagPriority
+//
+// Description: For the passed Tag entry, return the correct boot priority based on
+// the BootOptionTagPriorities global variable that is filled out
+// based on the SDL Token BOOT_OPTION_TAG_PRIORITIES.
+//
+// Input: UINT16 Tag - one of the following items of the BOOT_OPTION_TAG enum:
+//
+// Output: The index of this item in the FBODevMapData structure, which
+// also corresponds to the boot priority that should be assigned to this
+// class of device
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 FBO_FindTagPriority(UINT16 Tag){
+ UINT32 i=0;
+ UINT16 DeviceMapCount;
+
+ DeviceMapCount=GetDevMapDataCount( pFBOLegacyDevMap );
+
+ for( i=0; i<DeviceMapCount; i++ )
+ if( Tag == pFBOLegacyDevMap[i].DevType ) return i;
+
+ return UNASSIGNED_HIGHEST_TAG;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsUSBkeyByHandle
+//
+// Description: determine the device type of the USBKey size.
+//
+// Input: EFI_HANDLE Handle
+//
+// Output: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsUSBkeyByHandle(EFI_HANDLE Handle)
+{
+ EFI_BLOCK_IO_PROTOCOL *BlkIo;
+ UINT64 SizeInMb;
+ EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID;
+
+
+ if ( !EFI_ERROR( pBS->HandleProtocol(
+ Handle,
+ &gEfiBlockIoProtocolGuid,
+ &BlkIo)))
+ {
+ SizeInMb = MultU64x32(BlkIo->Media->LastBlock + 1, BlkIo->Media->BlockSize);
+ SizeInMb = DivU64x32(SizeInMb, 1000000, NULL);
+
+ if (SizeInMb <= USBKEY_RANGE_SIZE )
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+#if CSM_SUPPORT
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckIsUSBkey
+//
+// Description: Using the passed BBS_TABLE entry pointer, determine the device
+// type of the USBKey
+//
+// Input: BBS_TABLE *BbsEntry - pointer to a BBS_TABLE entry
+//
+// Output: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckIsUSBkey(BBS_TABLE *BbsEntry)
+{
+ if( BbsEntry->DeviceType == BBS_HARDDISK )
+ return IsUSBkeyByHandle( *(VOID**)(&BbsEntry->IBV1) );
+ else
+ return FALSE;
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_GetBbsEntryDeviceType
+//
+// Description: Using the passed BBS_TABLE entry pointer, determine the device
+// type of the associated device
+//
+// Input: BBS_TABLE *BbsEntry - pointer to a BBS_TABLE entry
+//
+// Output: UINT16 - device type
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 FBO_GetBbsEntryDeviceType(BBS_TABLE *BbsEntry){
+
+#ifdef CSM_SUPPORT
+ UINT16 i;
+ UINT16 DeviceType = BbsEntry->DeviceType;
+ BOOLEAN IsUSBDevice, IsUSBKey = FALSE;
+ UINT16 Matched=0, OldMatched=0, DevMapIndex = 0xff;
+ UINT16 DeviceMapCount=0;
+ CHAR8 *AsciiNameStr;
+
+ IsUSBDevice = (BbsEntry->Class == 0xc) && (BbsEntry->SubClass == 0x3);
+
+ if( IsUSBDevice )
+ IsUSBKey = CheckIsUSBkey( BbsEntry );
+
+#if BBS_NETWORK_DEVICE_TYPE_SUPPORT
+ if ( BbsEntry->Class == PCI_CL_NETWORK
+ && BbsEntry->DeviceType == BBS_BEV_DEVICE
+ ) DeviceType = BBS_EMBED_NETWORK;
+#endif
+
+ //Name from BBS table
+ AsciiNameStr = (CHAR8*)(UINTN)((BbsEntry->DescStringSegment<<4)
+ + BbsEntry->DescStringOffset);
+
+ TRACE((-1,"%s (IsUSBDevice=%d)(IsUSBKey=%d)\n", AsciiNameStr, IsUSBDevice, IsUSBKey));
+
+ DeviceMapCount=GetDevMapDataCount( pFBOLegacyDevMap );
+ for( i=0; i<DeviceMapCount; i++ )
+ {
+ Matched=1;
+ if( pFBOLegacyDevMap[i].BBSType != DeviceType ) continue;
+
+ if( IsUSBDevice && (pFBOLegacyDevMap[i].Attr & F_USB )) Matched++;
+ if( !IsUSBDevice && !(pFBOLegacyDevMap[i].Attr & F_USB )) Matched++;
+ if( IsUSBKey && (pFBOLegacyDevMap[i].Attr & F_USBKEY )) Matched++;
+ if( !IsUSBKey && !(pFBOLegacyDevMap[i].Attr & F_USBKEY )) Matched++;
+
+ if( pFBOLegacyDevMap[i].Port != 0xff )
+ if( pFBOLegacyDevMap[i].Port == GetDevicePortNumber( BbsEntry ) )
+ return pFBOLegacyDevMap[DevMapIndex].DevType;
+
+ if( Matched > OldMatched )
+ {
+ OldMatched = Matched;
+ DevMapIndex = i;
+ }
+ }
+
+ if( DevMapIndex != 0xff )
+ return pFBOLegacyDevMap[DevMapIndex].DevType;
+
+ TRACE((-1,"FBODevMapData not found\n"));
+ return BBS_UNKNOWN;
+#else
+ return 0;
+#endif //#ifdef CSM_SUPPORT
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildUEFIDevOrder
+//
+// Description: Go through the master boot option list and create
+// memory representation of the uefi dev order variable
+//
+// Input: DLIST *BootOptionList - the master boot option list
+//
+// Output: none
+//
+// Note:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BuildUEFIDevOrder(
+){
+ EFI_STATUS Status;
+ UINT16 i,j;
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ UINTN OldDvOrderSize=0;
+ UEFI_DEVICE_ORDER *OldDevOrder=NULL, *OldDevOrder2=NULL, *DevOrder=NULL, *DevOrder2=NULL;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ UINT16 DeviceMapCount;
+ UINT16 BootOrderFlag[128];
+
+ pBS->SetMem( BootOrderFlag, 128, 0);
+
+ Status = GetEfiVariable(L"UefiDevOrder", &FixedBootOrderGuid, NULL, &OldDvOrderSize, &OldDevOrder);
+ TRACE((-1,"FBOSetOrder.c BuildUEFIDevOrder:: GetEfiVariable UefiDevOrder (%r)\n", Status));
+ if( EFI_ERROR(Status) )
+ {
+ OldDvOrderSize = 0;
+ OldDevOrder = NULL;
+ }
+
+ DevOrder2 = DevOrder = Malloc(512);
+ if( DevOrder == NULL )
+ return;
+
+ DeviceMapCount=GetDevMapDataCount( pFBOUefiDevMap );
+ for(i=0; i<DeviceMapCount;i++)
+ {
+ UINT16 DevType;
+ DevType = pFBOUefiDevMap[i].DevType;
+ if( DevType == 0 ) break; //end of data
+ DevOrder->Type = DevType;
+ DevOrder->Length=2;
+
+ j=0;
+ //(EIP101213+)>
+ //collect new UEFI device to first position of group.
+ if(NewBootOptionNumber != 0xffff)
+ {
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if(Option->BootOptionNumber == NewBootOptionNumber)
+ {
+ if(GetUefiBootOptionTag(Option->FilePathList) == DevType)
+ {
+ DevOrder->Length += 2;
+ DevOrder->Device[j] = Option->BootOptionNumber;
+ BootOrderFlag[Option->BootOptionNumber]=0xffff; //mask flag.
+ if(!(Option->Attributes & LOAD_OPTION_ACTIVE))
+ DevOrder->Device[j] |= 0xff00;
+ j++;
+ break;
+ }
+ }
+ }
+ }
+ //<(EIP101213+)
+
+ //------------------------------------------------------------------------------
+ //Get Previous boot priority.
+ for( OldDevOrder2 = OldDevOrder
+ ;(UINT8*)OldDevOrder2<(UINT8*)OldDevOrder+OldDvOrderSize
+ ; OldDevOrder2 = (UEFI_DEVICE_ORDER*)((UINT8*)OldDevOrder2 + OldDevOrder2->Length + sizeof(OldDevOrder2->Type)) )
+ {
+ if( DevType != OldDevOrder2->Type ) continue;
+
+ {
+ UINT16 k;
+
+ for(k=0;k<(OldDevOrder2->Length-2)/sizeof(UINT16);k++)
+ {
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+
+ if( BootOrderFlag[Option->BootOptionNumber] ) continue; //not zero? //(EIP129692)
+ if(GetUefiBootOptionTag(Option->FilePathList) != DevType) continue; //(EIP100223+)
+ if(Option->BootOptionNumber == (OldDevOrder2->Device[k] & 0xff))
+ {
+ DevOrder->Length += 2;
+ DevOrder->Device[j] = Option->BootOptionNumber;
+ BootOrderFlag[Option->BootOptionNumber]=0xffff; //mask flag.
+ if(OldDevOrder2->Device[k] & 0xff00) //(EIP129692)
+ DevOrder->Device[j] |= 0xff00;
+ j++;
+ }
+ }
+ }
+ }
+ }
+ //------------------------------------------------------------------------------
+
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+
+ if( IsLegacyBootOption(Option) || Option->GroupHeader) continue;
+ if( BootOrderFlag[Option->BootOptionNumber] ) continue; //not zero?
+
+ if( GetUefiBootOptionTag(Option->FilePathList) == DevType )
+ {
+ DevOrder->Length += 2;
+ DevOrder->Device[j] = Option->BootOptionNumber;
+ if(!(Option->Attributes & LOAD_OPTION_ACTIVE))
+ DevOrder->Device[j] |= 0xff00;
+ j++;
+ }
+ }
+
+ if( DevOrder->Length > 2)
+ { //(EIP129692+)>
+ //re-alignment, move all disable item to last.
+ UINT16 DeviceCount;
+ DeviceCount=(DevOrder->Length-2)/sizeof(UINT16);
+ {
+ UEFI_DEVICE_ORDER *NewOrder=Malloc(DevOrder->Length+sizeof(DevOrder->Type));
+ if( NewOrder )
+ {
+ UINT16 NewOrderCount=0;
+
+ NewOrder->Type=DevOrder->Type;
+ NewOrder->Length=DevOrder->Length;
+
+ for(j=0; j<DeviceCount; j++)
+ {
+ if(DevOrder->Device[j] & 0xff00) continue;
+ NewOrder->Device[NewOrderCount]=DevOrder->Device[j];
+ NewOrderCount++;
+ }
+
+ for(j=0; j<DeviceCount; j++)
+ {
+ if(!(DevOrder->Device[j] & 0xff00)) continue;
+ NewOrder->Device[NewOrderCount]=DevOrder->Device[j];
+ NewOrderCount++;
+ }
+ pBS->CopyMem( DevOrder, NewOrder, DevOrder->Length+sizeof(DevOrder->Type) );
+ pBS->FreePool(NewOrder);
+ }
+ }
+ DevOrder = (UEFI_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type));
+ }
+ //<(EIP129692+)
+ }
+
+ {
+ UINTN DevOrderSize;
+ DevOrderSize = (UINT8*)DevOrder - (UINT8*)DevOrder2;
+
+ if(DevOrderSize)
+ {
+ pRS->SetVariable(
+ L"UefiDevOrder", &FixedBootOrderGuid,
+ BS_NV_VARIABLE_ATTRIBUTES, DevOrderSize, DevOrder2);
+
+ pRS->SetVariable(
+ L"OldUefiDevOrder", &FixedBootOrderGuid,
+ BS_NV_VARIABLE_ATTRIBUTES, DevOrderSize, DevOrder2);
+ }
+ else
+ {
+ pRS->SetVariable(
+ L"UefiDevOrder", &FixedBootOrderGuid,
+ 0, 0, NULL);
+
+ pRS->SetVariable(
+ L"OldUefiDevOrder", &FixedBootOrderGuid,
+ 0, 0, NULL);
+ }
+
+ }
+
+ pBS->FreePool( DevOrder2 );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: FBO_CompareTagThenBbsIndex
+//
+// Description: This function returns result of compairing two DLINK tags.
+//
+// Input:
+// Link1 - pointer to the first tag for compare
+// Link1 - pointer to the second tag for compare
+//
+// Output: INT32 - result of comparing.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INT32 FBO_CompareTagThenBbsIndex( IN DLINK *Link1, IN DLINK *Link2 )
+{
+ BOOT_OPTION *Option1 = (BOOT_OPTION*)Link1;
+ BOOT_OPTION *Option2 = (BOOT_OPTION*)Link2;
+
+ // Compare Tags first
+ if (Option1->Tag < Option2->Tag)
+ return -1;
+ else if (Option1->Tag > Option2->Tag)
+ return 1;
+
+ // Compare by BBS index
+ if (Option1->BbsIndex < Option2->BbsIndex)
+ return -1;
+ else if (Option1->BbsIndex > Option2->BbsIndex)
+ return 1;
+
+ return 0;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_SetDefaultUEFIDevOrder
+//
+// Description: Go through the master boot option list and create
+// memory representation of the default uefi order variable
+//
+// Input: DLIST *BootOptionList - the master boot option list
+//
+// Output: none
+//
+// Note:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FBO_SetDefaultUEFIDevOrder(
+){
+ UINT16 i,j;
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ UEFI_DEVICE_ORDER *DevOrder=NULL, *DevOrder2=NULL;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ UINT16 DeviceMapCount;
+
+ DevOrder2 = DevOrder = Malloc(512);
+
+ if( DevOrder == NULL )
+ return;
+
+ SortList(BootOptionList, FBO_CompareTagThenBbsIndex);
+
+ DeviceMapCount=GetDevMapDataCount( pFBOUefiDevMap );
+ for(i=0; i<DeviceMapCount;i++)
+ {
+ UINT16 DevType;
+ DevType = pFBOUefiDevMap[i].DevType;
+ if( DevType == 0 ) break; //end of data
+ DevOrder->Type = DevType;
+ DevOrder->Length=2;
+
+ j=0;
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+
+ if ( IsLegacyBootOption(Option) || Option->GroupHeader) continue;
+
+ if( GetUefiBootOptionTag(Option->FilePathList) == DevType )
+ {
+ DevOrder->Length += 2;
+ DevOrder->Device[j] = Option->BootOptionNumber;
+
+ j++;
+ }
+ }
+
+ //TRACE((-1,"DevType=%x DevOrder->Length=%x\n", DevType, DevOrder->Length));
+ if( DevOrder->Length > 2)
+ DevOrder = (UEFI_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type));
+ }
+
+ {
+ UINTN DevOrderSize;
+ DevOrderSize = (UINT8*)DevOrder - (UINT8*)DevOrder2;
+
+ if( DevOrderSize )
+ {
+ pRS->SetVariable(
+ L"DefaultUefiDevOrder", &FixedBootOrderGuid,
+ BS_NV_VARIABLE_ATTRIBUTES, DevOrderSize, DevOrder2);
+ }
+ else
+ {
+ pRS->SetVariable(
+ L"DefaultUefiDevOrder", &FixedBootOrderGuid,
+ 0, 0, NULL);
+ }
+
+ }
+
+ pBS->FreePool( DevOrder2 );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetLegacyBootOptionPriority
+//
+// Description: Set legacy boot option list priority.
+//
+// Input: DeviceType - Legacy Device type
+// Priority - pointer of Priority(UINT32).
+//
+// Output: none
+//
+// Note:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+SetLegacyBootOptionPriority(UINT16 DeviceType, UINT32 *Priority)
+{
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ BBS_BBS_DEVICE_PATH *BbsDp;
+
+ //Search Group Header
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ BbsDp = (BBS_BBS_DEVICE_PATH*)Option->FilePathList;
+ if(BbsDp->DeviceType != DeviceType ) continue;
+ if(!Option->GroupHeader) continue;
+
+ Option->Priority=++(*Priority);
+ Option->Attributes&=~LOAD_OPTION_HIDDEN;
+ Option->Attributes|=LOAD_OPTION_ACTIVE;
+
+ TRACE((-1,"[FBOSetOrder.c]Legacy Option->Priority=%x Name=%S\n", Option->Priority, Option->Description));
+// (*Priority)++;
+ break;
+ }
+
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if (!IsLegacyBootOption(Option)) continue; //Is Uefi? continue;
+ if(Option->GroupHeader) continue;
+
+ BbsDp = (BBS_BBS_DEVICE_PATH*)Option->FilePathList;
+ if(BbsDp->DeviceType != DeviceType ) continue;
+ Option->Priority=++(*Priority);
+// Option->Attributes|=LOAD_OPTION_ACTIVE;
+ TRACE((-1,"[FBOSetOrder.c]Legacy Option->Priority=%x Name=%S\n", Option->Priority, Option->Description));
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetUefiBootOptionPriority
+//
+// Description: Set uefi boot option list priority.
+//
+// Input: DeviceType - Uefi Device type
+// Priority - pointer of Priority(UINT32).
+//
+// Output: none
+//
+// Note:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+SetUefiBootOptionPriority(UINT16 DeviceType, UINT32 *Priority)
+{
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ UEFI_DEVICE_ORDER *DevOrder=NULL, *DevOrder2=NULL;
+ UINTN DevOrderSize=0;
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ UINT16 j;
+
+ GetEfiVariable(L"UefiDevOrder", &FixedBootOrderGuid, NULL, &DevOrderSize, &DevOrder);
+
+ DevOrder2=DevOrder;
+
+ for( DevOrder=DevOrder2
+ ;(UINT8*)DevOrder<(UINT8*)DevOrder2+DevOrderSize
+ ; DevOrder = (UEFI_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)) )
+ {
+ if( DeviceType != DevOrder->Type ) continue;
+
+ for(j=0; j<(DevOrder->Length-2)/sizeof(UINT16); j++)
+ {
+ TRACE((-1,"[FBOSetOrder.c]DevOrder->Device[%d]=%x\n", j, DevOrder->Device[j]));
+
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if(IsLegacyBootOption(Option)) continue;
+ if( Option->BootOptionNumber != (DevOrder->Device[j] & 0xff)) continue;
+
+ if( DevOrder->Device[j] & 0xff00 )
+ Option->Attributes&=~LOAD_OPTION_ACTIVE; //Disable
+ else
+ { //(EIP128779+)
+ Option->Attributes|=LOAD_OPTION_ACTIVE; //Enable
+ Option->Priority=++(*Priority); //(EIP128779+)
+ } //(EIP128779+)
+
+ Option->Attributes&=~LOAD_OPTION_HIDDEN;
+ TRACE((-1,"[FBOSetOrder.c]UEFI BootOptionNumber=%x Priority=%x Name=%S\n", Option->BootOptionNumber, Option->Priority, Option->Description));
+ break;
+ }
+ }
+ }
+
+ if( DevOrder2 )
+ pBS->FreePool( DevOrder2 );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_UpdateBootListPriority
+//
+// Description: use setup data LegacyPriorities/UefiPriorities/DualPriorities
+// ,set legacy/uefi boot option list priority.
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FBO_UpdateBootListPriority()
+{
+ EFI_STATUS Status;
+ EFI_GUID gSetupGuid=SETUP_GUID;
+ SETUP_DATA *pSetupData=NULL;
+ UINT32 SetupAttr;
+ UINTN SetupSize=0;
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ UINT16 i; //,j;
+ UINT16 DeviceMapCount=0;
+ UINT16 TypeIndex;
+ UINT32 PreviousPriority=0;
+
+//(EIP99368+)>>
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if (IsLegacyBootOption(Option)) continue;
+ if(!Wcscmp(Option->Description,L"USB Entry for Windows To Go Logo Test"))
+ return;
+ }
+//<<(EIP99368+)
+
+ BuildUEFIDevOrder();
+
+ Status = GetEfiVariable(L"Setup", &gSetupGuid, &SetupAttr, &SetupSize, &pSetupData);
+
+ if (EFI_ERROR(Status)) return;
+
+#if FBO_DUAL_MODE
+ if(pSetupData->BootMode == 2) //Is Dual boot mode?
+ {
+ //-----------------------------------------------------
+ //Search Legacy Group Header and Set is disable
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if (IsLegacyBootOption(Option)) //(EIP114186+)
+ Option->Priority=UNASSIGNED_HIGHEST_TAG; //(EIP114186+)
+ if(!Option->GroupHeader) continue;
+ Option->Attributes&=~LOAD_OPTION_ACTIVE;
+ Option->Priority=LOWEST_BOOT_OPTION_PRIORITY;
+ }
+ //-----------------------------------------------------
+ //Set All Uefi device Disable
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if (IsLegacyBootOption(Option)) continue;
+
+ if(Option->Attributes & LOAD_OPTION_HIDDEN) continue; //(EIP118170+)
+
+ Option->Attributes&=~LOAD_OPTION_ACTIVE; //Disable
+ Option->Priority=LOWEST_BOOT_OPTION_PRIORITY;
+ }
+ //-----------------------------------------------------
+ DeviceMapCount=GetDevMapDataCount( pFBODualDevMap );
+ for(i=0;i<DeviceMapCount;i++)
+ {
+ TypeIndex=pSetupData->DualPriorities[i];
+ if( !pFBODualDevMap[TypeIndex].BBSType ) //0, Uefi device
+ {
+ TRACE((-1,"[FBOSetOrder.c]DualPriorities[%d] pFBODualDevMap[%d].DevType=%x\n", i, TypeIndex, pFBODualDevMap[TypeIndex].DevType));
+ SetUefiBootOptionPriority( pFBODualDevMap[TypeIndex].DevType, &PreviousPriority );
+ }
+ else
+ {
+ if( pFBODualDevMap[TypeIndex].DevType == 0 ) continue; //Disable? //(EIP114186+)
+ TRACE((-1,"[FBOSetOrder.c]DualPriorities[%d] pFBODualDevMap[%d].DevType=%x\n", i, TypeIndex, pFBODualDevMap[TypeIndex].DevType));
+ SetLegacyBootOptionPriority( pFBODualDevMap[TypeIndex].DevType, &PreviousPriority );
+ }
+ }
+ }
+ else
+#endif
+ if(pSetupData->BootMode == 1) //Is Uefi boot mode?
+ {
+ //-----------------------------------------------------
+ //Set All device Disable
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if (IsLegacyBootOption(Option)) //(EIP107440)
+ if(!Option->GroupHeader) continue; //(EIP107440+)
+
+ if(Option->Attributes & LOAD_OPTION_HIDDEN) continue; //(EIP118170+)
+
+ Option->Attributes&=~LOAD_OPTION_ACTIVE; //Disable
+ Option->Priority=LOWEST_BOOT_OPTION_PRIORITY;
+ }
+ //-----------------------------------------------------
+ DeviceMapCount=GetDevMapDataCount( pFBOUefiDevMap );
+ for(i=0; i<DeviceMapCount;i++)
+ {
+ TypeIndex=pSetupData->UefiPriorities[i];
+
+ TRACE((-1,"[FBOSetOrder.c]UefiPriorities[%d] pFBOUefiDevMap[TypeIndex].DevType=%x\n", i, pFBOUefiDevMap[TypeIndex].DevType));
+ SetUefiBootOptionPriority( pFBOUefiDevMap[TypeIndex].DevType, &PreviousPriority );
+ }
+
+ //-----------------------------------------------------
+ //Set Other UEFI device priority
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+
+ if (IsLegacyBootOption(Option)
+ || (Option->Priority != LOWEST_BOOT_OPTION_PRIORITY) ) continue;
+
+ Option->Priority=++PreviousPriority;
+ TRACE((-1,"UEFI device Option->Priority=%x Name=%S\n", Option->Priority, Option->Description));
+
+ }
+ //-----------------------------------------------------
+
+ //-----------------------------------------------------
+ //Set Other Legacy device priority and hide
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+
+ if (!IsLegacyBootOption(Option)) continue;
+
+ Option->Priority=++PreviousPriority;
+ Option->Attributes|=LOAD_OPTION_HIDDEN;
+ TRACE((-1,"[FBOSetOrder.c]Legacy Option->Priority=%x Name=%S\n", Option->Priority, Option->Description));
+ }
+ //-----------------------------------------------------
+ }
+ else
+ if(pSetupData->BootMode == 0) //Is Legacy boot mode?
+ {
+ //-----------------------------------------------------
+ //Search Legacy Group Header and Set is disable
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if (IsLegacyBootOption(Option)) //(EIP114186+)
+ Option->Priority=UNASSIGNED_HIGHEST_TAG; //(EIP114186+)
+ if(!Option->GroupHeader) continue;
+ Option->Attributes&=~LOAD_OPTION_ACTIVE;
+ }
+
+ DeviceMapCount=GetDevMapDataCount( pFBOLegacyDevMap );
+ TRACE((-1,"[FBOSetOrder.c] DeviceMapCount=%x\n", DeviceMapCount));
+ for(i=0; i<DeviceMapCount;i++)
+ {
+ TypeIndex=pSetupData->LegacyPriorities[i];
+ if( pFBOLegacyDevMap[TypeIndex].DevType == 0 ) continue; //Disable? //(EIP114186+)
+ SetLegacyBootOptionPriority( pFBOLegacyDevMap[TypeIndex].DevType, &PreviousPriority );
+ }
+
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option){
+ if (IsLegacyBootOption(Option)) continue;
+ Option->Priority=++PreviousPriority;
+ Option->Attributes |= LOAD_OPTION_HIDDEN;
+ TRACE((-1,"[FBOSetOrder.c]UEFI Option->Priority=%x Name=%S\n", Option->Priority, Option->Description));
+ }
+ }
+ BuildFboLegacyDevOrder();
+
+ //
+ // Undesried boot options should be not able to boot (ACTIVE=0)
+ // This code must not be executed before BuildFboLegacyDevOrder
+ // in order to keep the FboLegacyDevOrder has the same disabled information as setup
+ //
+ FOR_EACH_BOOT_OPTION(BootOptionList, Link, Option)
+ {
+ UINT16 LegacyFlag = IsLegacyBootOption(Option);
+
+ if (pSetupData->BootMode == 2 // Dual mode?
+ || (pSetupData->BootMode == 0 && LegacyFlag) // legacy mode and legacy option?
+ || (pSetupData->BootMode == 1 && !LegacyFlag) // UEFI mode and UEFI option?
+ )
+ {
+ // option should be ACTIVE to boot and NOT HIDDEN for TSE
+ Option->Attributes &= ~LOAD_OPTION_HIDDEN; // clear HIDDEN for all legacy boot options
+ }
+ else
+ {
+ // undesried boot options for selected boot mode
+ // HIDDEN for TSE not sees it
+ // NOT ACTIVE for not booting from it
+ Option->Attributes |= LOAD_OPTION_HIDDEN; // HIDDEN
+ Option->Attributes &= ~LOAD_OPTION_ACTIVE; // Disable undesired UEFI boot options
+ }
+ }
+ pBS->FreePool(pSetupData);
+
+ DUMP_BOOT_OPTION_LIST(BootOptionList,"After UpdateBootListPriority");
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: BuildFboLegacyDevOrder
+//
+// Description: Build FboLegacyDevOrder variable from BootOptionList.
+// This variable should be set before we disable the undesried boot
+// options for selected boot mode. So we can get the correct
+// BootOptionList.Attributes reflecting the selection of setup.
+//
+// Input: None
+//
+// Output: FboLegacyDevOrder variable updated
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID BuildFboLegacyDevOrder()
+{
+#if CSM_SUPPORT
+ UINTN DevOrderSize;
+ LEGACY_DEVICE_ORDER *DevOrder, *DevOrderStart;
+ LEGACY_DEVICE_ORDER *NewDevOrder, *NewDevOrderStart;
+ UINT16 DeviceCount;
+ UINT16 i, j;
+
+ // return if no BootOption
+ if(!BootOptionList->Size)
+ return;
+
+ SortList(BootOptionList, ComparePriorityThenBootOptionNumber);
+ BuildLegacyDevOrderBuffer(&DevOrder, &DevOrderSize);
+
+ DevOrderStart = DevOrder;
+ //
+ // Crerate the NewDevOrder from DevOrder for changing order
+ //
+ NewDevOrderStart = NewDevOrder = MallocZ(DevOrderSize);
+ if (NewDevOrder == NULL)
+ {
+ pBS->FreePool(DevOrderStart);
+ return;
+ }
+ pBS->CopyMem(NewDevOrder, DevOrder, DevOrderSize);
+
+ //
+ // We need to keep the disabled ones at last
+ //
+ for (; (UINT8*)NewDevOrder < (UINT8*)NewDevOrderStart + DevOrderSize;)
+ {
+ j = 0;
+ DeviceCount = DEVORDER_COUNT(NewDevOrder);
+
+ //
+ // Save the enabled ones first
+ //
+ for (i = 0; i < DeviceCount; i++)
+ {
+ if (DevOrder->Device[i] & FBO_LEGACY_DISABLED_MASK)
+ {
+ continue;
+ }
+ NewDevOrder->Device[j++] = DevOrder->Device[i];
+ }
+ //
+ // Save the disabled ones later
+ //
+ for (i = 0; i < DeviceCount; i++)
+ {
+ if (!(DevOrder->Device[i] & FBO_LEGACY_DISABLED_MASK))
+ {
+ continue;
+ }
+ NewDevOrder->Device[j++] = DevOrder->Device[i];
+ }
+
+ //
+ // Next
+ //
+ NewDevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)NewDevOrder + NewDevOrder->Length + sizeof(NewDevOrder->Type));
+ DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type));
+ }
+
+ pRS->SetVariable(
+ L"FboLegacyDevOrder", &gFixedBootOrderGuid,
+ BS_NV_VARIABLE_ATTRIBUTES, DevOrderSize, NewDevOrderStart
+ );
+
+ pBS->FreePool(DevOrderStart);
+ pBS->FreePool(NewDevOrderStart);
+#endif //#if CSM_SUPPORT
+}
+ //(EIP101213+)>
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_AdjustWtgPriority()
+//
+// Description: First boot order of group, Change this gorup
+// uefi Priorities to Top position.
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void FBO_AdjustWtgPriority()
+{
+ EFI_STATUS Status;
+ UINT16 *BootOrder = NULL;
+ UINTN BootOrderSize = 0;
+ UINT32 SetupAttr;
+ UINTN SetupSize = 0;
+ SETUP_DATA *pSetupData = NULL;
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ EFI_GUID gSetupGuid = SETUP_GUID;
+ UINT16 i, TypeIndex;
+ UINT16 DeviceMapCount = 0;
+ BOOLEAN UpdateSetup = FALSE, WindowsToGoFound = FALSE;
+
+ Status = GetEfiVariable(L"Setup", &gSetupGuid, &SetupAttr, &SetupSize, &pSetupData);
+ if (EFI_ERROR(Status))
+ return;
+
+ // Search for Windwos To Go Boot Option
+ FOR_EACH_BOOT_OPTION(BootOptionList,Link,Option)
+ {
+ if (IsLegacyBootOption(Option))
+ continue;
+
+ // Found !!
+ if(!Wcscmp(Option->Description,L"USB Entry for Windows To Go")) //if WTG?
+ {
+ Status=GetEfiVariable(
+ L"BootOrder",
+ &EfiVariableGuid,
+ NULL,
+ &BootOrderSize,
+ &BootOrder);
+
+ if(EFI_ERROR(Status))
+ {
+ pBS->FreePool( pSetupData );
+ return;
+ }
+
+ // There are 2 Options in "Windows To Go Startup Options"
+ // Choose Yes, Windows will set Windows to Go BootOption to Frist Priority in BootOrder.
+ // Choose No, User Need to change PC's Firmware Setting.
+ // So, We Only handle the "Yes" Option
+
+ if(BootOrder[0] != Option->BootOptionNumber)
+ {
+ pBS->FreePool( pSetupData );
+ pBS->FreePool( BootOrder );
+ return;
+ }else
+ {
+ WindowsToGoFound = TRUE;
+ break;
+ }
+ }
+ }
+ if(!WindowsToGoFound)
+ {
+ pBS->FreePool( pSetupData );
+ return;
+ }
+
+#if FBO_DUAL_MODE
+ TypeIndex = SearchDevMapByType( pFBODualDevMap,GetUefiBootOptionTag(Option->FilePathList));
+ DeviceMapCount=GetDevMapDataCount( pFBODualDevMap );
+
+ for(i=0;i<DeviceMapCount;i++)
+ {
+ if(TypeIndex == pSetupData->DualPriorities[i])
+ {
+ UINT16 j;
+ UINT16 FirstPriority = pSetupData->DualPriorities[i];
+
+ for(j=i;j>0;j--)
+ pSetupData->DualPriorities[j] = pSetupData->DualPriorities[j-1];
+
+ pSetupData->DualPriorities[0] = FirstPriority;
+ UpdateSetup=TRUE;
+ break;
+ }
+ }
+#endif
+ TypeIndex = SearchDevMapByType( pFBOUefiDevMap,GetUefiBootOptionTag(Option->FilePathList));
+ DeviceMapCount = GetDevMapDataCount( pFBOUefiDevMap );
+ for(i = 0 ; i < DeviceMapCount ; i++)
+ {
+ if(TypeIndex == pSetupData->UefiPriorities[i])
+ {
+ UINT16 j;
+ UINT16 FirstPriority = pSetupData->UefiPriorities[i];
+
+ for(j = i ; j > 0 ; j--)
+ pSetupData->UefiPriorities[j] = pSetupData->UefiPriorities[j-1];
+
+ pSetupData->UefiPriorities[0] = FirstPriority;
+ UpdateSetup=TRUE;
+ break;
+ }
+ }
+
+ if(UpdateSetup)
+ Status = pRS->SetVariable(L"Setup",&gSetupGuid, SetupAttr, SetupSize, pSetupData);
+
+ pBS->FreePool( pSetupData );
+ pBS->FreePool( BootOrder );
+
+ return;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_AdjustPriority()
+//
+// Description: first boot order of group, Change this gorup
+// uefi and dual Priorities to Top position.
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void FBO_AdjustPriority()
+{
+ FBO_AdjustWtgPriority();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FBO_Init
+//
+// Description: Initialize the module memory, and device map data.
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FBO_Init(IN void)
+{
+ EFI_STATUS Status;
+ EFI_GUID FixedBootOrderGuid=FIXED_BOOT_ORDER_GUID;
+ EFI_FIXED_BOOT_ORDER_PROTOCOL *pFBO=NULL;
+ EFI_GUID gSetupGuid=SETUP_GUID;
+ SETUP_DATA *pSetupData=NULL;
+ UINT32 SetupAttr;
+ UINTN SetupSize=0;
+ UINT16 i, DeviceMapCount;
+
+ Status = pBS->LocateProtocol( &FixedBootOrderGuid, NULL, &pFBO );
+
+ if(!EFI_ERROR(Status))
+ {
+ pFBOLegacyDevMap = pFBO->GetLegacyDevMap();
+ pFBOUefiDevMap = pFBO->GetUefiDevMap();
+#if FBO_DUAL_MODE
+ pFBODualDevMap = pFBO->GetDualDevMap();
+#endif
+ }
+
+ Status = GetEfiVariable(L"Setup", &gSetupGuid, &SetupAttr, &SetupSize, &pSetupData);
+ if( !EFI_ERROR(Status) )
+ {
+ if( !pSetupData->FBO_Init )
+ {
+ pSetupData->FBO_Init=1;
+ //(EIP107268+)>
+#if USE_BCP_DEFAULT_PRIORITIES
+ DeviceMapCount=GetDevMapDataCount( pFBOLegacyDevMap );
+ for( i=0; i<DeviceMapCount; i++ )
+ pSetupData->LegacyPriorities[i]=pSetupData->BcpDefaultLegacyPriorities[i];
+
+ DeviceMapCount=GetDevMapDataCount( pFBOUefiDevMap );
+ for( i=0; i<DeviceMapCount; i++ )
+ pSetupData->UefiPriorities[i]=pSetupData->BcpDefaultUefiPriorities[i];
+ //(EIP122146+)>
+#if FBO_DUAL_MODE
+ DeviceMapCount=GetDevMapDataCount( pFBODualDevMap );
+ for( i=0; i<DeviceMapCount; i++ )
+ pSetupData->DualPriorities[i]=pSetupData->BcpDefaultDualPriorities[i];
+#endif
+ //<(EIP122146+)
+#else //<(EIP107268+)
+ DeviceMapCount=GetDevMapDataCount( pFBOLegacyDevMap );
+ for( i=0; i<DeviceMapCount; i++ )
+ pSetupData->LegacyPriorities[i]=i;
+
+ DeviceMapCount=GetDevMapDataCount( pFBOUefiDevMap );
+ for( i=0; i<DeviceMapCount; i++ )
+ pSetupData->UefiPriorities[i]=i;
+
+#if FBO_DUAL_MODE
+ DeviceMapCount=GetDevMapDataCount( pFBODualDevMap );
+ for( i=0; i<DeviceMapCount; i++ )
+ pSetupData->DualPriorities[i]=i;
+#endif
+
+#endif //#if USE_BCP_DEFAULT_PRIORITIES //(EIP107268+)
+
+ Status = pRS->SetVariable(L"Setup",&gSetupGuid, SetupAttr, SetupSize, pSetupData);
+ pBS->FreePool( pSetupData );
+ }
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FindLegacyDeviceGroupByType
+//
+// Description: Go through the legacy device order structure and find the legacy dev order
+// group type that we want then return this group.
+//
+// Input: LEGACY_DEVICE_ORDER *DevOrder - pointer to the legacy device order
+// UINTN DevOrderSize - size of the legacy dev order structure
+// UINT32 Type - Group type to match
+//
+// Output: LEGACY_DEVICE_ORDER *
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+LEGACY_DEVICE_ORDER* FindLegacyDeviceGroupByType(
+ LEGACY_DEVICE_ORDER *DevOrder, UINTN DevOrderSize, UINT32 Type
+)
+{
+ LEGACY_DEVICE_ORDER *LegacyGroup = DevOrder;
+
+ for (; (UINT8*)LegacyGroup < (UINT8*)DevOrder + DevOrderSize
+ ; (UINT8*)LegacyGroup += LegacyGroup->Length + sizeof(LegacyGroup->Type))
+ {
+ if (LegacyGroup->Type == Type) {
+ return LegacyGroup;
+ }
+ }
+
+ return NULL;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FboSyncBootOptionsFromDevOrder
+//
+// Description: UefiDevOrder and FboLegacyDevOrder variables contain the
+// disabled flags saved by setup. Need to update the disabled
+// flag to BootOptionList right before any other functions
+// that will process the BootOptionList.
+// BootOptionList will be set to NOT ACTIVE for disabled
+// DevOrder, ACTIVE for enabled one.
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+FboSyncBootOptionsFromDevOrder()
+{
+ LEGACY_DEVICE_ORDER *LegacyOrder = NULL, *LegacyGroup = NULL;
+ LEGACY_DEVICE_ORDER *OldLegacyOrder = NULL, *OldLegacyGroup = NULL;
+ UEFI_DEVICE_ORDER *UefiOrder = NULL, *UefiGroup = NULL;
+ UINTN DevOrderSize = 0;
+ UINTN OldDevOrderSize = 0;
+ DLINK *Link;
+ BOOT_OPTION *Option;
+ INT32 j;
+ EFI_STATUS Status;
+ UINT16 DeviceCount;
+ INT32 DevIndex;
+ UINT32 Type;
+
+ //
+ // Set ACTIVE information according to UefiDevOrder
+ //
+ Status = GetEfiVariable(L"UefiDevOrder", &gFixedBootOrderGuid, NULL, &DevOrderSize, &UefiOrder);
+ TRACE((-1, "[fbo] Get UefiDevOrder: %r\n", Status));
+ if (!EFI_ERROR(Status))
+ {
+ for (UefiGroup = UefiOrder
+ ; (UINT8*)UefiGroup < (UINT8*)UefiOrder + DevOrderSize
+ ; UefiGroup = (UEFI_DEVICE_ORDER*)((UINT8*)UefiGroup + UefiGroup->Length + sizeof(UefiGroup->Type)))
+ {
+ DeviceCount = DEVORDER_COUNT(UefiGroup);
+
+ // loop through boot option numbers within this group
+ for (j = 0; j < DeviceCount; j++)
+ {
+ // set up Option->Attributes.LOAD_OPTION_ACTIVE
+ FOR_EACH_BOOT_OPTION(BootOptionList, Link, Option)
+ {
+ if (IsLegacyBootOption(Option))
+ continue;
+
+ if ((UefiGroup->Device[j]&FBO_UEFI_ORDER_MASK) == Option->BootOptionNumber) // [31:24] = disabled flag
+ {
+ TRACE((-1, "[fbo] %S.Device[%d] = %x\n", Option->Description, j, UefiGroup->Device[j]));
+ if (UefiGroup->Device[j] & FBO_UEFI_DISABLED_MASK) // disabled?
+ Option->Attributes &= ~LOAD_OPTION_ACTIVE;
+ else
+ Option->Attributes |= LOAD_OPTION_ACTIVE;
+ }
+ }
+ }
+ }
+
+ }
+
+
+ //
+ // Set ACTIVE information according to FboLegacyDevOrder
+ //
+
+ // The flow of this FboLegacyDevOrder variable:
+ // 1. Updated the BootOptionList.Attributes from FboLegacyDevOrder right after boot options are
+ // read from NVRAM in FboSyncBootOptionsFromDevOrder() to reflect the setup controls.
+ // 2. Attributes will be changed to HIDDEN and NOT ACTIVE according to boot mode in FBO_UpdateBootListPriority().
+ // 3. Save the disabled information here for setup to use before we modifying the Attributes later
+ // in FBO_UpdateBootListPriority().
+ // 4. OldLegacyDevOrder variable indicates the sequence of legacy boot options by group in BootOptionList
+ // after reading from NVRAM, we need it to compare with FboLegacyDevOrder variable to find out options
+ // should set ACTIVE attribute or INACTIVE attribute.
+
+ Status = GetEfiVariable(L"FboLegacyDevOrder", &gFixedBootOrderGuid, NULL, &DevOrderSize, &LegacyOrder);
+ TRACE((-1, "[fbo] Get FboLegacyDevOrder: %r\n", Status));
+
+ if (!EFI_ERROR(Status))
+ {
+ Status = GetEfiVariable(L"OldLegacyDevOrder", &LegacyDevOrderGuid, NULL, &OldDevOrderSize, &OldLegacyOrder);
+ TRACE((-1, "[fbo] Get OldLegacyDevOrder: %r\n", Status));
+
+ //
+ // Only TRUE if..
+ // 1. Get variable successfully
+ // 2. Same size
+ // 3. Different contents
+ //
+ if (!EFI_ERROR(Status)
+ && OldDevOrderSize == DevOrderSize
+ && MemCmp(LegacyOrder, OldLegacyOrder, DevOrderSize))
+ {
+ UINT16 BootOptionNumber = INVALID_BOOT_OPTION_NUMBER;
+
+ FOR_EACH_BOOT_OPTION(BootOptionList, Link, Option)
+ {
+ if (!IsLegacyBootOption(Option) || Option->GroupHeader) continue;
+
+ if (BootOptionNumber != Option->BootOptionNumber) {
+
+ Type = BOOT_OPTION_GET_BBS_ENTRY_DEVICE_TYPE_FUNCTION(Option->BbsEntry);
+ LegacyGroup = FindLegacyDeviceGroupByType(LegacyOrder, DevOrderSize, Type);
+ OldLegacyGroup = FindLegacyDeviceGroupByType(OldLegacyOrder, OldDevOrderSize, Type);
+
+ j = 0;
+ BootOptionNumber = Option->BootOptionNumber;
+ }
+
+ if (LegacyGroup == NULL || OldLegacyGroup == NULL) continue;
+
+ DevIndex = FindPositionInTheGroupByBbsIndex(LegacyGroup, OldLegacyGroup->Device[j]);
+ // FixedBootOrderSaveChange function doesn't save FboLegacyDevOrder variable as
+ // group sequence we change in Setup, and that cause AdjustLegacyBootOptionPriorities
+ // function update the wrong Priority to Option, hence, we disable
+ // AdjustLegacyBootOptionPriorities function by SDL and update correct priority here.
+ Option->Priority += (DevIndex - j) * DEFAULT_PRIORITY_INCREMENT;
+ j++;
+
+ if (LegacyGroup->Device[DevIndex] & FBO_LEGACY_DISABLED_MASK)
+ {
+ Option->Attributes &= ~LOAD_OPTION_ACTIVE;
+ }
+ else
+ {
+ Option->Attributes |= LOAD_OPTION_ACTIVE;
+ }
+ }
+ }
+ }
+
+ if (OldLegacyOrder != NULL)
+ pBS->FreePool(OldLegacyOrder);
+ if (LegacyOrder != NULL)
+ pBS->FreePool(LegacyOrder);
+ if (UefiOrder != NULL)
+ pBS->FreePool(UefiOrder);
+
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Board/EM/FixedBootOrder/FixedBootOrder.c b/Board/EM/FixedBootOrder/FixedBootOrder.c
new file mode 100644
index 0000000..5c3a3ed
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrder.c
@@ -0,0 +1,3149 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrder.c $
+//
+// $Author: Dukeyeh $
+//
+// $Revision: 34 $
+//
+// $Date: 12/12/14 4:47a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrder.c $
+//
+// 34 12/12/14 4:47a Dukeyeh
+// [TAG] EIP176263
+// [Category] Bug Fix
+// [RootCause] The malfunction of GroupkeyProcess function that makes
+// duplicated devices in BBS priority menu of Setup.
+// [Solution] Update the comparision mechanism of GroupkeyProcess
+// function.
+// [Files] FixedBootOrder.c
+//
+// 33 10/08/14 1:45a Dukeyeh
+// [TAG] EIP184538
+// [Category] Improvement
+// [Description] FixedBootOrder changes the values of variables in
+// StdDefaults variable and updates their checksum also if need be.
+// [Files] FixedBootOrder.c
+// FixedBootOrder.mak
+//
+// 32 9/22/14 2:58a Dukeyeh
+// [TAG] EIP182196
+// [Category] Improvement
+// [Description] In order to adapt with UEFI spec. and TSE policy,
+// adding EFI_BROWSER_ACTION_DEFAULT_STANDARD action and returning
+// EFI_UNSUPPORTED to load default.
+// [Files] FixedBootOrder.c
+//
+// 31 9/09/14 3:36a Dukeyeh
+// [TAG] EIP171752
+// [Category] Improvement
+// [Description] Add FIXED_BOOT_ORDER_SUBMENU_MAX_NUM and
+// FIXED_BOOT_ORDER_GROUP_MAX_NUM tokens to decide maximum number of
+// submenus and groups at boot time.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+//
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 30 8/21/14 9:38a Dukeyeh
+// [TAG] EIP171752
+// [Category] Bug Fix
+// [RootCause] Need 33 bytes to save a BBS name(32 + one terminator),
+// not 32.
+// [Solution] Allocate 33 bytes for saving a BBS name.
+// [Files] FixedBootOrder.c
+//
+// 29 8/14/14 2:32a Walonli
+// [TAG] EIP180632
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Legacy device name show incorrect
+// [RootCause] String format incorrect with legacy option.
+// [Solution] Add Swprintf to covert string.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.c
+// FixedBootOrder.cif
+//
+// 28 8/13/14 11:19p Walonli
+// [TAG] EIP180632
+// [Category] New Feature
+// [Description] Add FixedBootOrder Protocol to change device/group
+// name.
+// [Files] Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// FixedBootOrder.cif
+//
+// 27 5/20/14 3:48a Klzhan
+// [TAG] EIP167196
+// [Category] Improvement
+// [Description] Runtime attribute set for the some of the variable used
+// by FixedBootOrder needs to be reviewed.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 26 4/15/14 2:26a Klzhan
+// [TAG] EIP143078
+// [Category] Improvement
+// [Description] Set LOAD_OPTION_ACTIVE must be 0 when
+// LOAD_OPTION_HIDDEN=1
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 25 11/18/13 10:19p Klzhan
+// [TAG] EIP137765
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Setup Item abnormal after remove USB KEY
+// [RootCause] BBS information will be deleted after removing USB key.
+// [Solution] Keep the Name string in a buffer
+//
+// 24 8/12/13 4:19a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] CppCheck error fix.
+// [Files] FixedBootOrder.c
+//
+// 23 5/31/13 1:45a Easonchen
+// [TAG] EIP123284
+// [Category] Improvement
+// [Description] Set Boot Priority unicode string
+// [Files] FixedBootOrder.c
+// FixedBootOrder.h
+// FixedBootOrder.sdl
+// FixedBootOrderTSE.c
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 22 5/28/13 5:26a Easonchen
+// [TAG] EIP122146
+// [Category] Improvement
+// [Description] Support Dual mode default priority with tool AMIBCP.
+// [Files]
+// FboSetOrder.c
+// FixedBootOrder.c
+// FixedBoorOrderTse.c
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 21 4/19/13 2:47a Easonchen
+// [TAG] EIP116436
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Fixed Boot Order doesn't work in Manufacturing mode
+// [RootCause] LegacyPriorities[],UefiPriorities[] not initializes in
+// Manufacturing mode
+// [Solution] set variable MfgDefaults, initial
+// LegacyPriorities[],UefiPriorities[] value.
+// [Files] FixedBootOrder.c
+//
+// 20 2/05/13 3:47a Easonchen
+// [TAG] EIP107268
+// [Category] Improvement
+// [Description] Add support managing default boot order list using
+// AMIBCP.
+// [Files]
+// FBOSetOrder.c
+// FixedBootOrder.c
+// FixedBootOrderTSE.c
+// FixedBootOrder.sdl
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 19 1/26/13 2:55a Easonchen
+// [TAG] EIP112714
+// [Category] Improvement
+// [Description] Add include file elink
+// [Files]
+// FixedBootOrder.c
+// FixedBootOrder.sdl
+// FixedBootOrder.mak
+//
+// 18 11/09/12 2:46a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] 1.Set Variable "StdDefaults" LegacyPriorities[],
+// UefiPriorities[] value
+// 2.Add TOKEN function
+// "INITIAL_LEGCAY_HII_ITEM_FUNCTION","INITIAL_UEFI_HII_ITEM_FUNCTION","IN
+// ITIAL_LEGCAY_GROUP_FUNCTION","INITIAL_UEFI_GROUP_FUNCTION"
+// [Files] FixedBootOrder.c
+//
+// 17 11/02/12 4:23a Easonchen
+// [TAG] EIP103171
+// [Category] Improvement
+// [Description] FixedBootOrder should not change setup.c after 4.6.5.4
+// [Files] FixedBootOrder.c
+//
+// 16 10/02/12 3:56a Easonchen
+// [TAG] EIP101408
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] FxiedBootOrder for multi-language problem
+// [RootCause] NewString don't support multi-language
+// [Solution] Add SetString for multi-language
+// [Files] FixedBootOrder.c
+//
+// 15 6/28/12 11:22a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+// functionality.
+//
+// 14 6/11/12 10:04a Easonchen
+// [TAG] EIP92141
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] build error with TSE 1227
+// [RootCause] TSE EDKhelper.c change function name DivU64x32 to
+// AmiTseDivU64x32.
+// [Solution] Change to use function Div64
+// [Files] FBOSetOrder.c
+//
+// 12 5/02/12 2:49a Easonchen
+// [TAG] EIP87316
+// [Category] Improvement
+// [Description] FixedBootOrder Module needs support CsmOptOut Boot
+// Filter UEFI Only. Set BBS Table BootPriority to BBS_IGNORE_ENTRY.
+// [Files] FBOSetOrder.c
+//
+// 11 6/17/11 3:44a Easonchen
+// [TAG] EIP57950
+// [Category] Improvement
+// [Description]
+// Replace BBS_TABLE BootPriority BBS_UNPRIORITIZED_ENTRY to
+// BBS_DO_NOT_BOOT_FROM.
+//
+// 10 4/14/11 4:01a Easonchen
+// TAG: EIP35562
+// In Core 4.6.4.1 or Last, Fixed boot variable name - hex digits should
+// be in upper case
+//
+// TAG: EIP54209
+// Improvement: NetBootHotKey eModule Functionality with TSE 1210
+// Verification Check
+// [Description]
+// Check TSE gBootFlow status in function FBOCheckNormalBoot
+//
+// TAG: EIP57727
+// Improvement: It always increase one device while reboot in F12 (Boot
+// device menu) even you only insert one HDD in it.
+// [Description]
+// Modify function UpdateBootOrder() and AddUEFIDevice() to support
+// 4.6.4.1
+//
+// 9 3/31/11 2:03a Easonchen
+// [TAG] EIP57272
+// [Category] Improvement
+// [Description] Check BootMode BOOT_ON_S4_RESUME and exit
+// [Files] FBOSetOrder.c
+//
+// 8 3/22/11 4:35a Easonchen
+// [TAG] EIP51709
+// [Category] Improvement
+// [Description] 1.Code is reformatted in accordance with the coding
+// standards.
+// 2.Remove file boot.vfr and setup.c, OEM need patch boot.vfr to remove
+// original boot options.
+//
+// 7 12/10/10 4:41a Easonchen
+// Minor bug fix (EIP47257.2)
+//
+// 6 11/12/10 2:57a Easonchen
+// Add TSE ELINK ProcessProceedToBootNowHook.
+//
+// TAG: EIP33514
+// Improvement: The FixedBootOrder function caused the side effect
+// -"AMT_TC010( IDE-Redirection).
+// [Description]
+// Check variable "AmtBootOption" created, OemFixedBootOrder() don't
+// change BBS_TABE Boot priority.
+//
+// TAG: EIP47257
+// Improvement: Load Default user define HDD order will lost.
+// [Description]
+// Modified routine BbsChecksum(), If can't get hard disk serial number.
+// use device name to make checksum.
+//
+// 5 9/14/10 3:04a Easonchen
+// TAG: EIP33514
+// Improvement: Modify function FixedBootOrderSaveChange().
+// [Description]
+// 1.Change BOOT#### LoadOption Bit Active status.
+// 2.Update variable BootOrder after SaveChange.
+// TAG: EIP33900
+// Improvement: add function FixedBootOrderLoadedConfigDefaults() for TSE
+// ELINK LoadedConfigDefaults().
+// [Description]
+// 1.Add function CreateDefaultDevOrder().
+// 2.Call FixedBootOrderProtocol->load_default_string().
+// TAG: EIP30275
+// Improvement: Windows Boot Manager delete and restore.
+// [Description]
+// 1.Add function WindowsBootManager().
+// TAG: EIP26947
+// Improvement: Update variable "BootOrder" and "LegacyDevOrder"
+// [Description]
+// 1.Add function UpdateBootOrder().
+// TAG: EIP22689
+// Improvement: Support submenu function.
+//
+// 4 3/31/10 6:54a Jameswang
+// [Tag] EIP35944
+// [Bug fix] Fixed USB CDROM will be analyzed as USB key with some CD
+// medium(HD format)
+// [Severity] Medium
+// [Root cause] We only checked the USB device size to determined if it is
+// a USB key, if USB CDROM has a medium that is emulated as a HDD / Floppy
+// between 2MB and 64GB then it will also be determined as USB key.
+// [Solution] Not only checks the size but also checks BBS types for HDD
+// and Floppy, excludes CDROM.
+//
+// 3 4/15/09 6:12a Jameswang
+// TAG: EIP19998
+// Improvement: New type:BOOT_USB_KEY is added and boot option can display
+// the device name.
+// [Description]
+// 1. Added BOOT_USB_KEY type: 64GB > USB KEY!=USB floppy >= 2MB
+// 2. SetPriorityForStringInit is added for pre-running the boot order for
+// each boot options, so the FixedBootOrderStringInit can add device names
+// to strings accordingly.
+// 3. When FixedBootOrderStringInit signaling a protocol event,
+// SetPriorityForStringInit::SetPriorityForStringInit will be called and
+// gInitStrPhase=TRUE, the BBS_TABLE[].BootPriority = BOOT_XXXX enum value
+// if the device is present.
+// 4. FBORegisterEvent is linked to MinisetupDriverEntryHook and register
+// a fake protocol so FixedBootOrderStringInit can signal it and callback
+// to SetPriorityForStringInit accross the EDK.
+//
+// 2 3/26/09 2:46a Jameswang
+// All include use <> only without any path. So that include files can be
+// override by CIF2MAK "/x" option.
+// All debug message add "\n".
+//
+// 1 3/02/09 3:31a Jameswang
+// Separate OemFixedBootOrder here to be linked with minisetup because we
+// changed to use eLinks instead of using events. We will not need to
+// modify bbs.c using eLinks.
+//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//**********************************************************************
+//
+// Name: FixedBootOrder.c
+//
+// Description: This file is linked to Setup Binary for form callback
+//
+//**********************************************************************
+//<AMI_FHDR_END>
+
+#include <token.h>
+#include <efi.h>
+#include <AmiDxeLib.h>
+#include <setup.h>
+
+#if CSM_SUPPORT
+#include <Protocol/LegacyBios.h>
+#endif
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+#include <Protocol/HiiConfigAccess.h>
+#include <Protocol/HiiString.h>
+#include <Protocol/HiiDatabase.h>
+#include <Protocol/FormBrowser2.h>
+#include <Protocol/HiiConfigRouting.h>
+#ifdef DEFAULT_LANGUAGE_CODE
+const char *DefaultLanguageCode = CONVERT_TO_STRING(DEFAULT_LANGUAGE_CODE);
+#endif
+#else //#if EFI_SPECIFICATION_VERSION>0x20000
+#include <FormCallback.h>
+#include <HIIDB.h>
+#include <Protocol/ExtHii.h>
+#endif
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+#include <Protocol/AmiSetupProtocol.h>
+#endif
+ //<(EIP103171+)
+
+#include <FixedBootOrderStrTokens.h> //(EIP112714)
+#include <FixedBootOrder.h>
+#include <FixedBootOrderHII.h>
+
+#include <AUTOID.h>
+#include <NVRAM.h>
+
+#pragma pack(1)
+typedef struct{
+ UINT32 Type;
+ UINT16 Length;
+ UINT16 Device[1];
+} LEGACY_DEVICE_ORDER;
+#pragma pack()
+
+BOOLEAN LoadedDefault = FALSE;
+
+#if CSM_SUPPORT
+BBS_TABLE *BbsTable = NULL;
+HDD_INFO *HddInfo;
+UINT16 HddCount=0;
+UINT16 BbsCount=0;
+UINT8 *BbsDeviceName = NULL;
+#define BBS_DEVICE_NAME_LENGTH 32
+#endif
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+static AMI_SETUP_PROTOCOL *AmiSetupProtocol = NULL;
+#endif
+ //<(EIP103171+)
+EFI_HII_STRING_PROTOCOL *gHiiString = NULL;
+CHAR8 Language[] = "en-US";
+EFI_HII_HANDLE FixedBoot_HiiHandle;
+
+EFI_GUID EfiVariableGuid = EFI_GLOBAL_VARIABLE;
+EFI_GUID LegacyDevOrderGuid = LEGACY_DEV_ORDER_GUID;
+EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+EFI_GUID DefaultLegacyDevOrderGuid = DEFAULT_LEGACY_DEV_ORDER_VARIABLE_GUID;
+
+FBODevMap *pFBODualDevMap = NULL;
+FBODevMap *pFBOLegacyDevMap = NULL;
+FBODevMap *pFBOUefiDevMap = NULL;
+FBOHiiMap *pFBOHiiMap = NULL;
+UINT16 *pBootOptionTokenMap = NULL; //(EIP123284+)
+
+CALLBACK_PARAMETERS *MyCallbackParametersPtr = NULL;
+CALLBACK_PARAMETERS *GetCallbackParameters();
+
+
+UINT8 TypeLegacyDeviceOptions[FIXED_BOOT_ORDER_GROUP_MAX_NUM][FIXED_BOOT_ORDER_SUBMENU_MAX_NUM];
+UINT8 TypeLegacyDeviceCount[FIXED_BOOT_ORDER_GROUP_MAX_NUM]; //GROUP
+UINT8 TypeUefiDeviceOptions[FIXED_BOOT_ORDER_GROUP_MAX_NUM][FIXED_BOOT_ORDER_SUBMENU_MAX_NUM];
+UINT8 TypeUefiDeviceCount[FIXED_BOOT_ORDER_GROUP_MAX_NUM]; //GROUP
+
+typedef EFI_STATUS (FBO_INITIAL_HII_ITEM)(EFI_HII_HANDLE HiiHandel);
+extern FBO_INITIAL_HII_ITEM INITIAL_LEGCAY_HII_ITEM_FUNCTION;
+FBO_INITIAL_HII_ITEM *InitialLegacyHiiItem = INITIAL_LEGCAY_HII_ITEM_FUNCTION;
+extern FBO_INITIAL_HII_ITEM INITIAL_UEFI_HII_ITEM_FUNCTION;
+FBO_INITIAL_HII_ITEM *InitialUefiHiiItem = INITIAL_UEFI_HII_ITEM_FUNCTION;
+
+typedef EFI_STATUS (FBO_INITIAL_GROUP)();
+extern FBO_INITIAL_GROUP INITIAL_LEGCAY_GROUP_FUNCTION;
+FBO_INITIAL_GROUP *InitLegacyGroup = INITIAL_LEGCAY_GROUP_FUNCTION;
+extern FBO_INITIAL_GROUP INITIAL_UEFI_GROUP_FUNCTION;
+FBO_INITIAL_GROUP *InitUefiGroup = INITIAL_UEFI_GROUP_FUNCTION;
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetDevMapDataCount
+//
+// Description: get the FBODevMap data amount.
+//
+// Input:
+// IN FBODevMap *pFBODevMap
+//
+// Output:
+// OUT UINT16
+//
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: None
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetDevMapDataCount(FBODevMap *pFBODevMap)
+{
+ UINT16 count = 0;
+
+ if( !pFBODevMap ) return 0; //end of data
+
+ do{
+ if( pFBODevMap[count].DevType == 0 ) break;
+ count++;
+ }while(1);
+
+ return count;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetHiiMapDataCount
+//
+// Description: get the FBOHiiMap data amount.
+//
+// Input:
+// None
+//
+// Output:
+// OUT UINT16
+//
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: None
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetHiiMapDataCount()
+{
+ UINT16 count = 0;
+
+ if( !pFBOHiiMap ) return 0; //end of data
+
+ do{
+ if( pFBOHiiMap[count].DevType == 0 ) break;
+ count++;
+ }while(1);
+
+ return count;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SearchDevMapByType
+//
+// Description: Search DevMap data index by device type.
+//
+// Input:
+// IN FBODevMap *pFBODevMap
+// IN UINT16 DevType
+//
+// Output:
+// OUT UINT16
+//
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: None
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 SearchDevMapByType(FBODevMap *pFBODevMap, UINT16 DevType)
+{
+ UINT16 i=0;
+
+ do{
+ if(pFBODevMap[i].DevType == 0 ) break; //end of data
+ if(pFBODevMap[i].DevType == DevType)
+ return i;
+ i++;
+ }while(1);
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SearchHiiMapByType
+//
+// Description: Search HiiMap data index by device type.
+//
+// Input:
+// IN UINT16 DevType
+//
+// Output:
+// OUT UINT16
+//
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: None
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 SearchHiiMapByType(UINT16 DevType)
+{
+ UINT16 i=0;
+
+ do{
+ if(pFBOHiiMap[i].DevType == 0 ) break; //end of data
+ if(pFBOHiiMap[i].DevType == DevType)
+ return i;
+ i++;
+ }while(1);
+
+ return 0;
+}
+
+/**
+ Compare whether two HDD device paths are the same.
+
+ @param DevDp1 Device path in comparison.
+ @param DevDp2 Device path in comparison.
+
+ @retval EFI_SUCCESS Two HDD paths are the same.
+ @retval EFI_NOT_FOUND Two Hdd paths are not the same.
+*/
+EFI_STATUS CompareHddDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevDp1, EFI_DEVICE_PATH_PROTOCOL *DevDp2 )
+{
+
+ if ( DevDp1->Type == MEDIA_DEVICE_PATH &&
+ DevDp1->SubType == MEDIA_HARDDRIVE_DP )
+ {
+ if (MemCmp(DevDp1+1, DevDp2+1, sizeof(HARDDRIVE_DEVICE_PATH)-sizeof(EFI_DEVICE_PATH_PROTOCOL)) == 0) //Skip Header EFI_DEVICE_PATH_PROTOCOL.
+ {
+ DevDp1 = NEXT_NODE(DevDp1);
+ if ( DevDp1->Type == MEDIA_DEVICE_PATH &&
+ DevDp1->SubType == MEDIA_FILEPATH_DP ) Wcsupr( (CHAR16*)DevDp1+1 );
+
+ DevDp2 = NEXT_NODE(DevDp2);
+ if ( DevDp2->Type == MEDIA_DEVICE_PATH &&
+ DevDp2->SubType == MEDIA_FILEPATH_DP ) Wcsupr( (CHAR16*)DevDp2+1 );
+
+ if (MemCmp(DevDp1, DevDp2, DPLength(DevDp2)) == 0)
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: IsDevicePathMatch
+//
+// Description: Judge Dp1 and Dp2 is same device path
+//
+// Input:
+// IN EFI_DEVICE_PATH_PROTOCOL *Dp1
+// IN EFI_DEVICE_PATH_PROTOCOL *Dp2
+//
+// Output:
+// TRUE : Same Device Path.
+// FALSE : Not same.
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: EIP 143657
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsDevicePathMatch(
+ IN EFI_DEVICE_PATH_PROTOCOL *Dp1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Dp2)
+{
+ // Check null device path
+ if (!Dp1 || !Dp2)
+ return FALSE ;
+
+ if (DPLength(Dp1) != DPLength(Dp2))
+ return FALSE ;
+
+ if (!MemCmp(Dp1, Dp2, DPLength(Dp1)))
+ return TRUE ;
+ else if (!CompareHddDevicePath(Dp1, Dp2))
+ return TRUE ;
+
+ return FALSE ;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: ChangeLegacyDeviceOptionName
+//
+// Description: Change Uefi Device option name in setup utility
+//
+// Input:
+// IN EFI_HANDLE Handle
+// IN OUT VOID *DevName
+//
+// Output:
+// IN OUT VOID *DevName
+// TRUE : Changed.
+// FALSE : Not Changed.
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: EIP 143657
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN ChangeLegacyDeviceOptionName(
+ IN EFI_HANDLE Handle,
+ IN OUT CHAR16 *DevName)
+{
+ EFI_STATUS Status ;
+ EFI_FIXED_BOOT_ORDER_PROTOCOL *FBOProtocol ;
+ Status = pBS->LocateProtocol (&FixedBootOrderGuid, NULL, &FBOProtocol);
+ if (!EFI_ERROR(Status))
+ {
+ EFI_DEVICE_PATH_PROTOCOL *Dp ;
+ Status = pBS->HandleProtocol(Handle, &gEfiDevicePathProtocolGuid, &Dp);
+ if (!EFI_ERROR(Status))
+ {
+ FBO_DEVICE_INFORM *DescriptionPtr ;
+ DescriptionPtr = FBOProtocol->GetNewDescription() ;
+ while( DescriptionPtr )
+ {
+ if (IsDevicePathMatch(Dp, DescriptionPtr->DevPath))
+ {
+ MemSet(DevName,0x100,0) ;
+ Wcscpy(DevName, DescriptionPtr->DevName) ;
+ TRACE((-1,"Set New Legacy Device Name: %S", DevName)) ;
+ return TRUE ;
+ }
+ DescriptionPtr = DescriptionPtr->Next ;
+ }
+ }
+ }
+ return FALSE ;
+
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: ChangeUefiDeviceOptionName
+//
+// Description: Change Uefi Device option name in setup utility
+//
+// Input:
+// IN EFI_LOAD_OPTION *BootOption
+// IN OUT VOID *DevName
+//
+// Output:
+// IN OUT VOID *DevName
+// TRUE : Changed.
+// FALSE : Not Changed.
+// Modified: None
+//
+// Referrals: None
+//
+// Notes: EIP 143657
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN ChangeUefiDeviceOptionName(
+ IN EFI_LOAD_OPTION *BootOption,
+ IN OUT VOID **DevName)
+{
+ EFI_STATUS Status ;
+ EFI_FIXED_BOOT_ORDER_PROTOCOL *FBOProtocol ;
+ Status = pBS->LocateProtocol (&FixedBootOrderGuid, NULL, &FBOProtocol);
+ if (!EFI_ERROR(Status))
+ {
+ FBO_DEVICE_INFORM *DescriptionPtr ;
+ UINT8 *FilePathList ;
+ UINTN OldNameSize ;
+ OldNameSize = (Wcslen((CHAR16*)(BootOption+1))+1)*sizeof(CHAR16);
+ FilePathList = (UINT8*)(BootOption+1)+OldNameSize;
+ DescriptionPtr = FBOProtocol->GetNewDescription() ;
+ while( DescriptionPtr )
+ {
+ if (IsDevicePathMatch((EFI_DEVICE_PATH_PROTOCOL*)FilePathList, DescriptionPtr->DevPath))
+ {
+ *DevName = DescriptionPtr->DevName ;
+ TRACE((-1,"Set New Uefi Device Name: %S", (CHAR16*)*DevName)) ;
+ return TRUE ;
+ }
+ DescriptionPtr = DescriptionPtr->Next ;
+ }
+ }
+ return FALSE ;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FBO_AdjustGroupName
+//
+// Description: Change FBO Group Name
+//
+// Input:
+//
+// Output:
+//
+// Referrals: None
+//
+// Notes: EIP 143657
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+FBO_AdjustGroupName()
+{
+ EFI_STATUS Status ;
+ CHAR8* Languages = NULL, *OrgLanguages = NULL;
+ UINT16 x ;
+ UINT16 HiiSize = GetHiiMapDataCount() ;
+ UINT32 Attr ;
+ UINTN *GroupPtrAddr = NULL;
+ UINTN LangSize = 0, Size = 0 ;
+ UINTN OptionMaxSize = 0x100;
+ BOOLEAN LastLanguage = FALSE;
+ FBO_GROUP_OPTION *Group = NULL, *PreGroup = NULL ;
+
+ if (gHiiString == NULL)
+ Status = pBS->LocateProtocol(&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gHiiString);
+ if (EFI_ERROR(Status))return;
+
+ Status = gHiiString->GetLanguages(gHiiString, FixedBoot_HiiHandle, Languages, &LangSize);
+ if (Status == EFI_BUFFER_TOO_SMALL)
+ {
+ Status = pBS->AllocatePool(EfiBootServicesData, LangSize, &Languages);
+ if (EFI_ERROR(Status)) return; //not enough resources to allocate string
+ Status = gHiiString->GetLanguages(gHiiString, FixedBoot_HiiHandle, Languages, &LangSize);
+ }
+ if (EFI_ERROR(Status)) return;
+
+ // Get Pointer Address
+ Status = GetEfiVariable(L"FboGroupNameData", &FixedBootOrderGuid, &Attr, &Size, &GroupPtrAddr);
+ if ( EFI_ERROR(Status)) return ;
+
+ OrgLanguages = Languages ;
+ while(!LastLanguage)
+ {
+ CHAR8* CurrentLanguage, StrSaveTemp ;
+ CurrentLanguage = Languages; //point CurrentLanguage
+ while (*Languages != ';' && *Languages != 0)
+ Languages++;
+
+ StrSaveTemp = *Languages;
+ *Languages = 0; //put null-terminator
+
+ Group = (FBO_GROUP_OPTION*)*GroupPtrAddr ;
+ while (Group)
+ {
+ for ( x=0; x < HiiSize ; x++ )
+ {
+ if (Group->StrToken == pFBOHiiMap[x].StrToken )
+ {
+ TRACE((-1,"FixedBootOrder.c AdjustFBOGroupName Change Group Name(StrToken)\n")) ;
+ Status = gHiiString->SetString(gHiiString, FixedBoot_HiiHandle, pFBOHiiMap[x].StrToken,
+ CurrentLanguage, Group->NewGroupName, NULL);
+ }
+ else
+ {
+ CHAR16 *TempString = MallocZ(OptionMaxSize) ;
+ Size = OptionMaxSize ;
+ Status = gHiiString->GetString(gHiiString, CurrentLanguage, FixedBoot_HiiHandle,
+ pFBOHiiMap[x].StrToken, TempString, &Size, NULL);
+ // if string match, update the new group name.
+ if (Group->OrgGroupName && !Wcscmp(TempString, Group->OrgGroupName))
+ {
+ TRACE((-1,"FixedBootOrder.c AdjustFBOGroupName Change Group Name(OrgName)\n")) ;
+ Status = gHiiString->SetString(gHiiString, FixedBoot_HiiHandle, pFBOHiiMap[x].StrToken,
+ CurrentLanguage, Group->NewGroupName, NULL);
+ }
+ pBS->FreePool(TempString) ;
+ }
+ }
+ Group = Group->Next ;
+ }
+ *Languages = StrSaveTemp;
+
+ if (*Languages == 0) //last language in language list
+ LastLanguage = TRUE ;
+ else
+ Languages++ ;
+ }
+
+
+ // Free all pointer and content
+ while (Group)
+ {
+ PreGroup = Group;
+ Group = Group->Next;
+ pBS->FreePool(PreGroup);
+ }
+ Status = pRS->SetVariable(L"FboGroupNameData", &FixedBootOrderGuid, 0, 0, NULL);
+ pBS->FreePool(OrgLanguages) ;
+ pBS->FreePool(GroupPtrAddr) ;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetUEFIBootName
+//
+// Description: Get Variable Boot#### and return data pointer.
+//
+// Input:
+// IN UINT16 BootIndex
+//
+// Output:
+// EFI_LOAD_OPTION
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_LOAD_OPTION* GetUEFIBootName(IN UINT16 BootIndex)
+{
+// EFI_GUID EfiVariableGuid = EFI_GLOBAL_VARIABLE;
+ EFI_STATUS Status;
+ UINTN OptionSize;
+ CHAR16 BootVarName[15];
+
+ Swprintf( BootVarName, gBootName, BootIndex); //(EIP35562)
+
+ OptionSize = 0;
+ Status = pRS->GetVariable( BootVarName, &EfiVariableGuid, NULL, &OptionSize, NULL);
+ if(Status != EFI_NOT_FOUND)
+ {
+ EFI_LOAD_OPTION *BootOption = NULL; //buffer for BootXXX variables
+
+ BootOption=Malloc( OptionSize );
+ Status = pRS->GetVariable( BootVarName, &EfiVariableGuid, NULL, &OptionSize, BootOption);
+ if(!EFI_ERROR(Status))
+ return BootOption;
+ }
+ return NULL;
+
+}
+ //(EIP101408+)>
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: UpdateDeviceHiiString
+//
+// Description: Update device item multi-language Hii string
+//
+// Input:
+// UINT16 StrToken
+// CHAR16 *DeviceName
+//
+// Output:
+// None
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void UpdateDeviceHiiString(IN UINT16 StrToken, IN CHAR16 *DeviceName)
+{
+ EFI_STATUS Status;
+ CHAR8* Languages = NULL;
+ CHAR8* OrgLanguages = NULL;
+ UINTN LangSize = 0;
+ BOOLEAN LastLanguage = FALSE;
+ CHAR8 StrSaveTemp;
+ UINTN i, Size=0;
+ CHAR16 OldStr[0x100],DeviceStr[0x100];
+
+ if(gHiiString == NULL) {
+ Status = pBS->LocateProtocol(&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gHiiString);
+ if(EFI_ERROR(Status))
+ return;
+ }
+
+ Status = gHiiString->GetLanguages(gHiiString, FixedBoot_HiiHandle, Languages, &LangSize);
+ if(Status == EFI_BUFFER_TOO_SMALL) {
+ Status = pBS->AllocatePool(EfiBootServicesData, LangSize, &Languages);
+ if(EFI_ERROR(Status))
+ return; //not enough resources to allocate string
+ Status = gHiiString->GetLanguages(gHiiString, FixedBoot_HiiHandle, Languages, &LangSize);
+ }
+ if(EFI_ERROR(Status))
+ return;
+
+ OrgLanguages = Languages;
+ while(!LastLanguage) {
+ CHAR8* CurrentLanguage;
+ CurrentLanguage = Languages; //point CurrentLanguage to start of new language
+ while(*Languages != ';' && *Languages != 0)
+ Languages++;
+
+ StrSaveTemp = *Languages;
+ *Languages = 0; //put null-terminator
+ Size=0x100;
+ TRACE((-1,"CurrentLanguage=%s\n", CurrentLanguage));
+ Status=gHiiString->GetString(gHiiString, CurrentLanguage, FixedBoot_HiiHandle, StrToken, OldStr, &Size, NULL);
+ *Languages = StrSaveTemp;
+
+ if( EFI_ERROR(Status) ) //Language not define in .uni
+ {
+ if(*Languages == 0) //last language in language list
+ LastLanguage = TRUE;
+ else
+ {
+ *Languages = ';'; //restore original character
+ Languages++;
+ }
+ continue;
+ }
+
+
+ //removec char ":"
+ for( i=0; i<Wcslen(OldStr); i++ )
+ {
+ if( OldStr[i] == 0x003A )
+ {
+ OldStr[i] = (CHAR16)0;
+ break;
+ }
+ }
+
+ if( DeviceName == NULL )
+ Swprintf( DeviceStr, L"%s", OldStr);
+ else
+ Swprintf( DeviceStr, L"%s:%s", OldStr, DeviceName);
+
+ if(*Languages == 0) { //last language in language list
+ LastLanguage = TRUE;
+ Status = gHiiString->SetString(gHiiString, FixedBoot_HiiHandle, StrToken, CurrentLanguage, DeviceStr, NULL);
+ if(EFI_ERROR(Status))
+ {pBS->FreePool(OrgLanguages); return;}
+ } else {
+ *Languages = 0; //put null-terminator
+ Status = gHiiString->SetString(gHiiString, FixedBoot_HiiHandle, StrToken, CurrentLanguage, DeviceStr, NULL);
+ *Languages = ';'; //restore original character
+ Languages++;
+ if(EFI_ERROR(Status))
+ {pBS->FreePool(OrgLanguages); return;}
+ }
+ }
+
+ if( OrgLanguages )
+ pBS->FreePool(OrgLanguages);
+}
+
+ //<(EIP101408+)
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: UpdateLegacyDeviceHiiString
+//
+// Description: Update boot option type string token
+//
+// Input:
+// IN UINT16 DevType
+// IN UINT8 Index
+//
+// Output:
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void UpdateLegacyDeviceHiiString(IN UINT16 DevType, IN UINT8 Index)
+{
+#if CSM_SUPPORT
+ EFI_STATUS Status;
+ VOID *DevOrderBuffer = NULL;
+ UINTN BBSNamePtr;
+ UINTN Size=0;
+ CHAR16 DeviceName[0x100];
+ UINT16 HiiDevMapIndex, HiiDevMapCount;
+
+ HiiDevMapCount = GetHiiMapDataCount();
+ for( HiiDevMapIndex=0; HiiDevMapIndex<HiiDevMapCount; HiiDevMapIndex++ )
+ {
+ if( pFBOHiiMap[HiiDevMapIndex].DevType == DevType )
+ break;
+ }
+
+ if (Index >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ {
+ UpdateDeviceHiiString( pFBOHiiMap[HiiDevMapIndex].StrToken, NULL); //(EIP101408+)
+ }
+ else
+ {
+ if(LoadedDefault)
+ Status = GetEfiVariable(L"DefaultLegacyDevOrder", &DefaultLegacyDevOrderGuid, NULL, &Size, &DevOrderBuffer);
+ else
+ Status = GetEfiVariable( L"FboLegacyDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer );
+
+ if (!EFI_ERROR(Status) && Size >= 6)
+ {
+ UINTN j;
+ LEGACY_DEVICE_ORDER *DevOrder;
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ; DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)) )
+ {
+
+ if(DevOrder->Type != DevType) continue;
+ if(DevOrder->Length <= 2) continue;
+
+ j= DevOrder->Device[Index] & 0xff;
+
+ {
+ char *pStr;
+ UINTN x ;
+
+ if( BbsDeviceName )
+ BBSNamePtr = (UINTN)&BbsDeviceName[j*(BBS_DEVICE_NAME_LENGTH+1)];
+ else
+ {
+ BBSNamePtr = (UINTN)( ((UINTN)BbsTable[j].DescStringSegment<<4)
+ + BbsTable[j].DescStringOffset );
+ }
+
+ pStr=(char *)BBSNamePtr;
+ for(x=0; x<10 ;x++)
+ {
+ if( *pStr == ':')
+ {
+ BBSNamePtr += x + 1;
+ break;
+ }
+ else
+ pStr++;
+ }
+ Swprintf(DeviceName, L"%a", BBSNamePtr);
+ ChangeLegacyDeviceOptionName((EFI_HANDLE)BbsTable[j].IBV1,(CHAR16*)&DeviceName) ;
+ UpdateDeviceHiiString(pFBOHiiMap[HiiDevMapIndex].StrToken, DeviceName);
+ }
+ break;
+ } //for( DevOrder = DevOrderBuffer..........
+ } //if (!EFI_ERROR(Status) && Size>=6)
+
+ if(DevOrderBuffer != NULL)
+ pBS->FreePool(DevOrderBuffer);
+ }
+#endif //#if CSM_SUPPORT
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: UpdateUefiDeviceHiiString
+//
+// Description: Update boot option type string token
+//
+// Input:
+// IN UINT16 DevType
+// IN UINT8 Index
+//
+// Output:
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void UpdateUefiDeviceHiiString(IN UINT16 DevType, IN UINT8 Index)
+{
+ EFI_STATUS Status;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ VOID *DevOrderBuffer = NULL;
+ UINTN Size=0;
+ UINT16 i=0, HiiDevMapIndex, HiiDevMapCount;
+
+ HiiDevMapCount = GetHiiMapDataCount();
+ for( HiiDevMapIndex=0; HiiDevMapIndex<HiiDevMapCount; HiiDevMapIndex++ )
+ {
+ if( pFBOHiiMap[HiiDevMapIndex].DevType == DevType )
+ break;
+ }
+
+ if(Index >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ {
+ UpdateDeviceHiiString( pFBOHiiMap[HiiDevMapIndex].StrToken, NULL); //(EIP101408+)
+ }
+ else
+ {
+ if(LoadedDefault)
+ Status = GetEfiVariable(L"DefaultUefiDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer);
+ else
+ Status = GetEfiVariable( L"UefiDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer );
+
+ if (!EFI_ERROR(Status) && Size >= 6)
+ {
+ UINTN j;
+ LEGACY_DEVICE_ORDER *DevOrder;
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ; DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)) )
+ {
+
+ if(DevOrder->Type != DevType) continue;
+ if(DevOrder->Length <= 2) continue;
+
+ j= DevOrder->Device[Index] & 0xff;
+
+ {
+ EFI_LOAD_OPTION *BootOption=NULL;
+ BootOption=GetUEFIBootName( (UINT16)j );
+ if( BootOption )
+ {
+ UINT8 *NameStr;
+
+ NameStr=((UINT8*)BootOption)+sizeof(EFI_LOAD_OPTION);
+ ChangeUefiDeviceOptionName(BootOption,&NameStr) ;
+ UpdateDeviceHiiString(pFBOHiiMap[HiiDevMapIndex].StrToken, (CHAR16*)NameStr);
+ pBS->FreePool( BootOption );
+ }
+ }
+ break;
+ } //for( DevOrder = DevOrderBuffer..........
+ } //if (!EFI_ERROR(Status) && Size>=6)
+
+ if(DevOrderBuffer != NULL)
+ pBS->FreePool(DevOrderBuffer);
+ }
+}
+
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GroupkeyProcess
+//
+// Description: Avoid each group boot priorities from being duplicated to each
+// other by using INTERACTIVE callback.
+//
+// Input:
+// IN OUT UINT8 *NewBootDevice
+// IN UINT8 *OldBootDevice
+// IN UINT8 DeviceIndex
+// IN UINT8 DeviceCount
+//
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GroupkeyProcess(IN OUT UINT8 *NewBootDevice, IN UINT8 *OldBootDevice, IN UINT8 DeviceIndex, IN UINT8 DeviceCount)
+{
+ UINTN i;
+ UINT8 NewVal = NewBootDevice[DeviceIndex];
+ UINT8 OldVal = OldBootDevice[DeviceIndex];
+
+
+ for (i = 0; i < DeviceCount ; i++)
+ TRACE((-1, "%d ", NewBootDevice[i]));
+ TRACE((-1,"\n"));
+
+ if(OldVal == NewVal)
+ {
+ return EFI_SUCCESS;
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ else if( OldVal == FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ {
+ //
+ // Disabled to Enabled
+ //
+ for(i = 0; i < DeviceIndex; i++)
+ {
+ //
+ // Duplicated value
+ //
+ if(OldBootDevice[i] == NewVal)
+ {
+ NewBootDevice[DeviceIndex] = FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ break;
+ }
+
+ //
+ // Find first disabled device then exchange
+ //
+ if(NewBootDevice[i] == FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ {
+ NewBootDevice[i] = NewVal;
+ NewBootDevice[DeviceIndex] = FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ break;
+ }
+ }
+ }
+ else if(NewVal == FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ {
+ //
+ // Enabled to Disabled
+ //
+
+ UINTN j = DeviceIndex;
+ for(i = j + 1; i < DeviceCount; i++)
+ {
+ //
+ // Move disabled one to last step by step.
+ //
+ if(NewBootDevice[i] != FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ {
+ NewBootDevice[j] = NewBootDevice[i];
+ NewBootDevice[i] = FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ j = i;
+ }
+
+ }
+ }
+#endif
+ else
+ {
+ //
+ // Both are not equal and disabled.
+ //
+ for(i = 0; i < DeviceCount; i++)
+ {
+ if(i == DeviceIndex)
+ continue;
+ if(NewVal == NewBootDevice[i])
+ NewBootDevice[i] = OldVal;
+ }
+ }
+
+
+ for(i=0;i< DeviceCount ;i++)
+ {
+ OldBootDevice[i] = NewBootDevice[i];
+ TRACE((-1,"%d ",NewBootDevice[i]));
+ }
+ TRACE((-1,"\n"));
+
+ return EFI_SUCCESS;
+}
+
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FixedBootOrderFormCallBack
+//
+// Description: Avoid each boot priorities from being duplicated to each
+// other by using INTERACTIVE callback.
+//
+// Input:
+// IN EFI_HII_HANDLE HiiHandle
+// IN UINT16 Class
+// IN UINT16 SubClass
+// IN UINT16 KeyValue
+//
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FixedBootOrderFormCallBack (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN UINT16 Class,
+ IN UINT16 SubClass,
+ IN UINT16 KeyValue
+)
+{
+ EFI_STATUS Status=EFI_SUCCESS;
+ EFI_GUID gSetupGuid = SETUP_GUID;
+ UINT16 Current, Swap=0xffff, MapPri=0;
+ UINT16 Mapped[16];
+ UINT16 i=0, DeviceCount;
+ BOOLEAN Uefi_Boot_item = FALSE;
+#if FBO_DUAL_MODE
+ BOOLEAN Dual_Boot_item = FALSE;
+#endif
+ UINT16 Offset;
+ UINT8 DeviceIndex;
+ UINT16 DevTypeIndex;
+ SETUP_DATA pSetup;
+ SETUP_DATA *IfrNvData = &pSetup;
+ UINTN BufferSize;
+ BufferSize = sizeof (SETUP_DATA);
+
+ MyCallbackParametersPtr=GetCallbackParameters();
+ TRACE((-1,"[FixedBootOrder.c] Action=%X\n",MyCallbackParametersPtr->Action));
+
+#if (EFI_SPECIFICATION_VERSION >= 0x2000A)
+ if (MyCallbackParametersPtr->Action == EFI_BROWSER_ACTION_CHANGING)
+ return EFI_SUCCESS;
+ else if (MyCallbackParametersPtr->Action == EFI_BROWSER_ACTION_DEFAULT_STANDARD)
+ return EFI_UNSUPPORTED;
+ else if (MyCallbackParametersPtr->Action != EFI_BROWSER_ACTION_CHANGED)
+ return EFI_INVALID_PARAMETER;
+#endif
+
+ KeyValue = MyCallbackParametersPtr->KeyValue;
+ TRACE((-1,"[FixedBootOrder.c] ***** INTERACTIVE callback. KEY=%X\n",KeyValue));
+
+ if( KeyValue < FixedBootOrderStratKey ) return EFI_UNSUPPORTED; //Check Is FixedBootOrder assigned keys?
+
+ //--------------------------------------
+ //SubMenu UEFI Boot device change process
+ //--------------------------------------
+ if( KeyValue >= UefiForms_StartKey )
+ {
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ UINT16 DevType=0;
+#endif
+ FIXED_BOOT_SETUP *IfrNvDataSubMenu=NULL;
+ //
+ // Retrive uncommitted data from Browser
+ //
+ BufferSize = sizeof (FIXED_BOOT_SETUP);
+ pBS->AllocatePool (EfiBootServicesData, BufferSize, &IfrNvDataSubMenu);
+ ASSERT (IfrNvDataSubMenu != NULL);
+
+ Status = HiiLibGetBrowserData( &BufferSize, IfrNvDataSubMenu, &gSetupGuid, L"FixedBoot");
+ TRACE((-1,"[FixedBootOrder.c] HiiLibGetBrowserData(%r) BufferSize=%x\n", Status, BufferSize));
+ if (EFI_ERROR (Status)) {
+ pBS->FreePool (IfrNvDataSubMenu);
+ return Status;
+ }
+
+ Offset = (KeyValue - UefiForms_StartKey);
+ DevTypeIndex = Offset / FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ DeviceIndex = Offset % FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ GroupkeyProcess( &IfrNvDataSubMenu->UefiDevice[DevTypeIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM],
+ &TypeUefiDeviceOptions[DevTypeIndex][0],
+ DeviceIndex,
+ TypeUefiDeviceCount[DevTypeIndex] );
+
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ DevType=pFBOUefiDevMap[DevTypeIndex].DevType;
+ UpdateUefiDeviceHiiString( DevType, TypeUefiDeviceOptions[DevTypeIndex][0]);
+#endif
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+ Status = HiiLibSetBrowserData( BufferSize, IfrNvDataSubMenu, &gSetupGuid, L"FixedBoot");
+ TRACE((-1,"[FixedBootOrder.c] HiiLibSetBrowserData(%r) BufferSize=%x\n", Status, BufferSize));
+ pBS->FreePool (IfrNvDataSubMenu);
+#endif
+ return Status;
+ }
+ else
+ //--------------------------------------
+ //SubMenu Legacy Boot device change process
+ //--------------------------------------
+ if( KeyValue >= LegacyForms_StartKey )
+ {
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ UINT16 DevType=0;
+#endif
+ FIXED_BOOT_SETUP *IfrNvDataSubMenu=NULL;
+ //
+ // Retrive uncommitted data from Browser
+ //
+ BufferSize = sizeof (FIXED_BOOT_SETUP);
+ pBS->AllocatePool (EfiBootServicesData, BufferSize, &IfrNvDataSubMenu);
+ ASSERT (IfrNvDataSubMenu != NULL);
+
+ Status = HiiLibGetBrowserData( &BufferSize, IfrNvDataSubMenu, &gSetupGuid, L"FixedBoot");
+ TRACE((-1,"[FixedBootOrder.c] HiiLibGetBrowserData(%r) BufferSize=%x\n", Status, BufferSize));
+ if (EFI_ERROR (Status)) {
+ pBS->FreePool (IfrNvDataSubMenu);
+ return Status;
+ }
+
+ Offset = (KeyValue - LegacyForms_StartKey);
+ DevTypeIndex = Offset / FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ DeviceIndex = Offset % FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ GroupkeyProcess( &IfrNvDataSubMenu->LegacyDevice[DevTypeIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM],
+ &TypeLegacyDeviceOptions[DevTypeIndex][0],
+ DeviceIndex,
+ TypeLegacyDeviceCount[DevTypeIndex] );
+
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ DevType=pFBOLegacyDevMap[DevTypeIndex].DevType;
+ UpdateLegacyDeviceHiiString( DevType, TypeLegacyDeviceOptions[DevTypeIndex][0]);
+#endif
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+ Status = HiiLibSetBrowserData( BufferSize, IfrNvDataSubMenu, &gSetupGuid, L"FixedBoot");
+ TRACE((-1,"[FixedBootOrder.c] HiiLibSetBrowserData(%r) BufferSize=%x\n", Status, BufferSize));
+ pBS->FreePool (IfrNvDataSubMenu);
+#endif
+
+ return Status;
+ }
+
+ //--------------------------------------
+ //Legacy & Uefi Boot item change process
+ //--------------------------------------
+#if FBO_DUAL_MODE
+ if( KeyValue >= DualBootItemKey )
+ {
+ DeviceCount = GetDevMapDataCount(pFBODualDevMap);
+ Dual_Boot_item=TRUE;
+ }
+ else
+#endif
+ if( KeyValue >= UefiBootItemKey )
+ {
+ DeviceCount = GetDevMapDataCount(pFBOUefiDevMap);
+ Uefi_Boot_item=TRUE;
+ }
+ else
+ {
+ DeviceCount = GetDevMapDataCount(pFBOLegacyDevMap);
+ Uefi_Boot_item=FALSE;
+ }
+
+ KeyValue = (KeyValue & 0x7f)+1;
+ Current = MyCallbackParametersPtr->Value->u16; // current user selection
+ //
+ // Retrive uncommitted data from Browser
+ //
+ Status = HiiLibGetBrowserData( &BufferSize, IfrNvData, &gSetupGuid, L"Setup");
+ if (EFI_ERROR (Status)) {
+ TRACE((-1,"FixedBootOrder.c HiiLibGetBrowserData (%r)\n", Status));
+ return Status;
+ }
+
+ TRACE((-1,"[FixedBootOrder.c] Current=%X\n",Current));
+
+ // Init all Mapped to FALSE
+ for (i=0; i<DeviceCount; i++)
+ Mapped[i]=FALSE;
+
+ // Find duplicated boot order to (Swap)
+ for (i=0; i<DeviceCount; i++)
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ MapPri=IfrNvData->DualPriorities[i];
+ else
+#endif
+ if(Uefi_Boot_item)
+ MapPri=IfrNvData->UefiPriorities[i];
+ else
+ MapPri=IfrNvData->LegacyPriorities[i];
+
+ TRACE((0x800,"[FixedBoot] Priorities[%d]=%d\n", i, MapPri));
+
+ if ( MapPri == Current && i+1 != KeyValue && Current < DeviceCount)
+ {
+ // i = duplicated index
+ Swap = i;
+ TRACE((0x800,"[FixedBoot] Need to change Priorities[%d]\n", Swap));
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ if( MapPri == DeviceCount) continue; //is Disable?
+#endif
+ Mapped[MapPri]=TRUE; // TRUE = priority set
+ }
+
+ if (Swap == 0xffff) // not found duplicated?
+ return EFI_SUCCESS;
+
+ // Change the duplicated value according to Mapped[]
+ for (i=0; i<DeviceCount; i++)
+ {
+ if (Mapped[i] == FALSE) // This priority #i is not set yet
+ {
+#if FIXED_BOOT_SWAP_POLICY == 0 // just swap the duplicated
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ IfrNvData->DualPriorities[Swap] = i; // not minus nor plus, just make no duplication
+ else
+#endif
+ if(Uefi_Boot_item)
+ IfrNvData->UefiPriorities[Swap] = i; // not minus nor plus, just make no duplication
+ else
+ IfrNvData->LegacyPriorities[Swap] = i; // not minus nor plus, just make no duplication
+#endif //#if FIXED_BOOT_SWAP_POLICY == 0
+
+#if FIXED_BOOT_SWAP_POLICY == 1 // move up or down
+ UINT16 Val1;
+ UINT16 Val2;
+ BOOLEAN PlusWrap;
+ BOOLEAN MinusWrap;
+ UINT16 NewVal;
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ NewVal = IfrNvData->DualPriorities[Swap]; // new value
+ else
+#endif
+ if(Uefi_Boot_item)
+ NewVal = IfrNvData->UefiPriorities[Swap];
+ else
+ NewVal = IfrNvData->LegacyPriorities[Swap]; // new value
+
+ if (MinusWrap = (i == 0 && NewVal == DeviceCount-1)) // old = 0, new = last, wrapped?
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ IfrNvData->DualPriorities[KeyValue-1] = 0;
+ else
+#endif
+ if(Uefi_Boot_item)
+ IfrNvData->UefiPriorities[KeyValue-1] = 0;
+ else
+ IfrNvData->LegacyPriorities[KeyValue-1] = 0;
+ }
+
+ if (PlusWrap = (i == DeviceCount-1 && NewVal == 0)) // old = last, new = 0, wrapped?
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ IfrNvData->DualPriorities[KeyValue-1] = i;
+ else
+#endif
+ if(Uefi_Boot_item)
+ IfrNvData->UefiPriorities[KeyValue-1] = i;
+ else
+ IfrNvData->LegacyPriorities[KeyValue-1] = i;
+ }
+ // Prohibit wrapping
+
+ if(KeyValue == 1) // first one?
+ {
+ if (MinusWrap) // wrap?
+ continue; // skip
+ if (NewVal == i-1) // -1?
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ IfrNvData->DualPriorities[KeyValue-1] = NewVal+1;
+ else
+#endif
+ if(Uefi_Boot_item)
+ IfrNvData->UefiPriorities[KeyValue-1] = NewVal+1;
+ else
+ IfrNvData->LegacyPriorities[KeyValue-1] = NewVal+1;
+ continue;
+ }
+ }
+
+ if (KeyValue == DeviceCount) // last one?
+ {
+ if (PlusWrap) // wrap?
+ continue; // skip
+ if (NewVal == i+1) // +1?
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ IfrNvData->DualPriorities[KeyValue-1] = NewVal-1;
+ else
+#endif
+ if(Uefi_Boot_item)
+ IfrNvData->UefiPriorities[KeyValue-1] = NewVal-1;
+ else
+ IfrNvData->LegacyPriorities[KeyValue-1] = NewVal-1;
+ continue;
+ }
+ }
+
+
+ if (NewVal == i-1 || MinusWrap) // new = old-1 or wrapped?
+ {
+ // Minus
+
+// if (KeyValue!=1) // !=1? (1-based)
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ {
+ if (!MinusWrap)
+ IfrNvData->DualPriorities[KeyValue-1]++; // +1 because it was -1 by "-" key
+
+ Val1 = IfrNvData->DualPriorities[KeyValue-2]; // previous
+ Val2 = IfrNvData->DualPriorities[KeyValue-1]; // current
+ IfrNvData->DualPriorities[KeyValue-2]=Val2;
+ IfrNvData->DualPriorities[KeyValue-1]=Val1;
+ }
+ else
+#endif
+ if(Uefi_Boot_item)
+ {
+ if (!MinusWrap)
+ IfrNvData->UefiPriorities[KeyValue-1]++; // +1 because it was -1 by "-" key
+
+ Val1 = IfrNvData->UefiPriorities[KeyValue-2]; // previous
+ Val2 = IfrNvData->UefiPriorities[KeyValue-1]; // current
+ IfrNvData->UefiPriorities[KeyValue-2]=Val2;
+ IfrNvData->UefiPriorities[KeyValue-1]=Val1;
+ }
+ else
+ {
+ if (!MinusWrap)
+ IfrNvData->LegacyPriorities[KeyValue-1]++; // +1 because it was -1 by "-" key
+
+ Val1 = IfrNvData->LegacyPriorities[KeyValue-2]; // previous
+ Val2 = IfrNvData->LegacyPriorities[KeyValue-1]; // current
+ IfrNvData->LegacyPriorities[KeyValue-2]=Val2;
+ IfrNvData->LegacyPriorities[KeyValue-1]=Val1;
+ }
+ }
+ }
+ else
+ {
+ if (NewVal == i+1 || PlusWrap) // new = old+1 or wrapped?
+ {
+ // Plus
+// if (KeyValue!=FIXED_BOOT_TOTAL_BOOT_OPTIONS) // != last?
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ {
+ if (!PlusWrap)
+ IfrNvData->DualPriorities[KeyValue-1]--; // -1 because it was +1 by "+" key
+
+ Val1 = IfrNvData->DualPriorities[KeyValue-1]; // current
+ Val2 = IfrNvData->DualPriorities[KeyValue]; // next
+ IfrNvData->DualPriorities[KeyValue-1]=Val2;
+ IfrNvData->DualPriorities[KeyValue]=Val1;
+ }
+ else
+#endif
+ if(Uefi_Boot_item)
+ {
+ if (!PlusWrap)
+ IfrNvData->UefiPriorities[KeyValue-1]--; // -1 because it was +1 by "+" key
+
+ Val1 = IfrNvData->UefiPriorities[KeyValue-1]; // current
+ Val2 = IfrNvData->UefiPriorities[KeyValue]; // next
+ IfrNvData->UefiPriorities[KeyValue-1]=Val2;
+ IfrNvData->UefiPriorities[KeyValue]=Val1;
+ }
+ else
+ {
+ if (!PlusWrap)
+ IfrNvData->LegacyPriorities[KeyValue-1]--; // -1 because it was +1 by "+" key
+
+ Val1 = IfrNvData->LegacyPriorities[KeyValue-1]; // current
+ Val2 = IfrNvData->LegacyPriorities[KeyValue]; // next
+ IfrNvData->LegacyPriorities[KeyValue-1]=Val2;
+ IfrNvData->LegacyPriorities[KeyValue]=Val1;
+ }
+ }
+ }
+ else
+ {
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ IfrNvData->DualPriorities[Swap] = i; // not minus nor plus, just make no duplication
+ else
+#endif
+ if(Uefi_Boot_item)
+ IfrNvData->UefiPriorities[Swap] = i; // not minus nor plus, just make no duplication
+ else
+ IfrNvData->LegacyPriorities[Swap] = i; // not minus nor plus, just make no duplication
+ }
+ }
+#endif //#if FIXED_BOOT_SWAP_POLICY == 1
+#if FBO_DUAL_MODE
+ if(Dual_Boot_item)
+ TRACE((0x800,"[FixedBoot] NEW DualPriorities[%d]=%d\n", Swap, IfrNvData->DualPriorities[Swap] ));
+ else
+#endif
+ if(Uefi_Boot_item)
+ TRACE((0x800,"[FixedBoot] NEW UefiPriorities[%d]=%d\n", Swap, IfrNvData->UefiPriorities[Swap] ));
+ else
+ TRACE((0x800,"[FixedBoot] NEW LegacyPriorities[%d]=%d\n", Swap, IfrNvData->LegacyPriorities[Swap] ));
+ break;
+ }
+
+ }
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+ Status = HiiLibSetBrowserData( BufferSize, IfrNvData, &gSetupGuid, L"Setup" );
+ TRACE((-1,"FixedBootOrder.c HiiLibSetBrowserData (%r)\n", Status));
+#endif
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: InitLegacyGroupDefault
+//
+// Description: Each group device name Hii String Update, and fixed HiiDB Oneof
+// Data.
+//
+//
+// Input:
+//
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitLegacyGroupDefault()
+{
+#if CSM_SUPPORT
+EFI_STATUS Status;
+VOID *DevOrderBuffer = NULL;
+UINT16 i, j, DevMapIndex;
+UINTN BBSNamePtr;
+UINTN Size = 0;
+UINT8 DeviceItem =0, DisableItem = 0;
+CHAR16 DeviceName[0x100];
+HII_DEVICE_INFO *pHiiDevTokenData = NULL;
+UINTN HiiDevDataSize=0;
+
+ if( LoadedDefault )
+ Status = GetEfiVariable( L"DefaultLegacyDevOrder", &DefaultLegacyDevOrderGuid, NULL, &Size, &DevOrderBuffer);
+ else
+ Status = GetEfiVariable( L"FboLegacyDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer );
+
+ if (!EFI_ERROR(Status) && Size>6)
+ {
+ LEGACY_DEVICE_ORDER *DevOrder;
+ HII_DEVICE_INFO *HiiDevOrder;
+
+ Status = GetEfiVariable( L"FixedHiiLegacyDevData", &FixedBootOrderGuid, NULL, &HiiDevDataSize, &pHiiDevTokenData );
+ if(EFI_ERROR(Status)) return Status;
+
+ HiiDevOrder = pHiiDevTokenData;
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ;DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(UINT32)) )
+ {
+ UINT16 SubmenuIndex;
+ DeviceItem=0;
+ DisableItem=0;
+
+ SubmenuIndex = SearchHiiMapByType( DevOrder->Type );
+ DevMapIndex = SearchDevMapByType( pFBOLegacyDevMap, DevOrder->Type);
+ if( pFBOHiiMap[SubmenuIndex].FormID != 0 )
+ {
+ for( HiiDevOrder = pHiiDevTokenData
+ ;(UINT8*)HiiDevOrder<(UINT8*)pHiiDevTokenData+HiiDevDataSize
+ ;HiiDevOrder = (HII_DEVICE_INFO*)((UINT8*)HiiDevOrder + HiiDevOrder->Length + sizeof(UINT32)) )
+ {
+ if( HiiDevOrder->Type == DevOrder->Type )
+ break;
+ }
+ }
+
+ for(i=0; i<(DevOrder->Length-2)/sizeof(UINT16); i++)
+ {
+ j= DevOrder->Device[i] & 0xff;
+
+ if( pFBOHiiMap[SubmenuIndex].FormID != 0 )
+ {
+ if( BbsDeviceName )
+ BBSNamePtr = (UINTN)&BbsDeviceName[j*(BBS_DEVICE_NAME_LENGTH+1)];
+ else
+ {
+ BBSNamePtr = (UINTN)( ((UINTN)BbsTable[j].DescStringSegment<<4)
+ + BbsTable[j].DescStringOffset );
+ }
+
+ Swprintf(DeviceName, L"%a", BBSNamePtr);
+ ChangeLegacyDeviceOptionName((EFI_HANDLE)BbsTable[j].IBV1,(CHAR16*)&DeviceName) ;
+ InitString(FixedBoot_HiiHandle, HiiDevOrder->StrToken[i], L"%s", DeviceName);
+
+ TRACE((-1, "BBS DEVICE(%d):%S \n", i, DeviceName));
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ if( DevOrder->Device[i] & 0xff00 )
+ {
+ TypeLegacyDeviceOptions[DevMapIndex][DeviceItem+DisableItem]=FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ DisableItem++;
+ }
+ else
+#endif
+ {
+ TypeLegacyDeviceOptions[DevMapIndex][DeviceItem+DisableItem]=DeviceItem+DisableItem;
+ DeviceItem++;
+ }
+ if ((DeviceItem + DisableItem) >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+
+ }
+
+
+
+ TRACE((-1,"[FixedBoot] DeviceItem=%d DisableItem=%d \n", DeviceItem, DisableItem));
+
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ if(DeviceItem)
+ UpdateLegacyDeviceHiiString(DevOrder->Type, 0);
+ else
+ UpdateLegacyDeviceHiiString(DevOrder->Type, FIXED_BOOT_ORDER_SUBMENU_MAX_NUM); //no device, show type
+#endif
+
+ TypeLegacyDeviceCount[DevMapIndex]=DeviceItem;
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ if(DisableItem)
+ TypeLegacyDeviceCount[DevMapIndex]+=DisableItem;
+#endif
+ TRACE((-1,"[FixedBoot] Type(%x)DevCount=%x\n",DevMapIndex, TypeLegacyDeviceCount[DevMapIndex]));
+ }
+ }
+
+ if( DevOrderBuffer )
+ pBS->FreePool( DevOrderBuffer );
+ if( pHiiDevTokenData )
+ pBS->FreePool( pHiiDevTokenData );
+#endif //#if CSM_SUPPORT
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: InitUefiGroupDefault
+//
+// Description: Each group device name Hii String Update, and fixed HiiDB Oneof
+// Data.
+//
+//
+// Input:
+// NONE
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitUefiGroupDefault()
+{
+EFI_STATUS Status;
+EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+VOID *DevOrderBuffer = NULL;
+UINT16 i, j, DevMapIndex;
+//UINTN BBSNamePtr;
+UINTN Size = 0;
+UINT8 DeviceItem =0, DisableItem = 0;
+//CHAR16 DeviceName[0x100];
+HII_DEVICE_INFO *pHiiDevTokenData = NULL;
+UINTN HiiDevDataSize=0;
+
+ if( LoadedDefault )
+ Status = GetEfiVariable( L"DefaultUefiDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer);
+ else
+ Status = GetEfiVariable( L"UefiDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer );
+
+ if (!EFI_ERROR(Status) && Size>6)
+ {
+ LEGACY_DEVICE_ORDER *DevOrder;
+ HII_DEVICE_INFO *HiiDevOrder;
+
+ Status = GetEfiVariable( L"FixedHiiUefiDevData", &FixedBootOrderGuid, NULL, &HiiDevDataSize, &pHiiDevTokenData );
+ if(EFI_ERROR(Status)) return Status;
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ;DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(UINT32)) )
+ {
+ UINT16 SubmenuIndex;
+ DeviceItem=0;
+ DisableItem=0;
+
+ SubmenuIndex = SearchHiiMapByType( DevOrder->Type );
+ DevMapIndex = SearchDevMapByType( pFBOUefiDevMap, DevOrder->Type);
+ if( pFBOHiiMap[SubmenuIndex].FormID != 0 )
+ {
+
+ for( HiiDevOrder = pHiiDevTokenData
+ ;(UINT8*)HiiDevOrder<(UINT8*)pHiiDevTokenData+HiiDevDataSize
+ ;HiiDevOrder = (HII_DEVICE_INFO*)((UINT8*)HiiDevOrder + HiiDevOrder->Length + sizeof(UINT32)) )
+ {
+ if( HiiDevOrder->Type == DevOrder->Type )
+ break;
+ }
+ }
+
+ for(i=0; i<(DevOrder->Length-2)/sizeof(UINT16); i++)
+ {
+ EFI_LOAD_OPTION *BootOption=NULL;
+
+ j= DevOrder->Device[i] & 0xff;
+
+ BootOption=GetUEFIBootName(j);
+ if( BootOption )
+ {
+ if( pFBOHiiMap[SubmenuIndex].FormID != 0 )
+ {
+ CHAR16 *NameStr;
+ NameStr=(CHAR16*)((UINT8*)BootOption+sizeof(EFI_LOAD_OPTION));
+ ChangeUefiDeviceOptionName(BootOption,&NameStr) ; // (EIP143657+)
+ InitString(FixedBoot_HiiHandle, HiiDevOrder->StrToken[i], L"%s", NameStr);
+ TRACE((-1,"UEFI DEVICE(%d):%S \n", i, NameStr));
+ }
+ pBS->FreePool( BootOption );
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ if( DevOrder->Device[i] & 0xff00 )
+ {
+ TypeUefiDeviceOptions[DevMapIndex][DeviceItem+DisableItem] = FIXED_BOOT_ORDER_SUBMENU_MAX_NUM;
+ DisableItem++;
+ }
+ else
+#endif
+ {
+ TypeUefiDeviceOptions[DevMapIndex][DeviceItem+DisableItem]=DeviceItem+DisableItem;
+ DeviceItem++;
+ }
+ if ((DeviceItem + DisableItem) >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+ }
+ TRACE((-1,"[FixedBoot] DeviceItem=%d DisableItem=%d \n", DeviceItem, DisableItem));
+
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ if(DeviceItem)
+ UpdateUefiDeviceHiiString(DevOrder->Type, 0);
+ else
+ UpdateUefiDeviceHiiString(DevOrder->Type, FIXED_BOOT_ORDER_SUBMENU_MAX_NUM); //no device, show type
+#endif
+
+ TypeUefiDeviceCount[DevMapIndex]=DeviceItem;
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ if(DisableItem)
+ TypeUefiDeviceCount[DevMapIndex]+=DisableItem;
+#endif
+ TRACE((-1,"[FixedBoot] Type(%x)DevCount=%x\n",DevMapIndex, TypeUefiDeviceCount[DevMapIndex]));
+ }
+ }
+
+ if( DevOrderBuffer )
+ pBS->FreePool( DevOrderBuffer );
+ if( pHiiDevTokenData )
+ pBS->FreePool( pHiiDevTokenData );
+
+ return EFI_SUCCESS;
+}
+ //(EIP101408+)>
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: HiiAddLanguageBootOptionString
+//
+// Description: Install multi-language for STR_BOOT_OPTION.
+//
+// Input:
+// NONE
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+STRING_REF HiiAddLanguageBootOptionString(IN EFI_HII_HANDLE HiiHandle, IN UINT16 BootOptionNumber)
+{
+ EFI_STATUS Status;
+ CHAR8* Languages = NULL;
+ CHAR8* OrgLanguages = NULL;
+ UINTN LangSize = 0;
+ BOOLEAN LastLanguage = FALSE;
+ STRING_REF StringId = 0;
+ CHAR8 StrSaveTemp;
+
+ UINTN Size=0;
+ CHAR16 BootOptionStr[0x100];
+ CHAR16 BootStr[32];
+
+ if(gHiiString == NULL) {
+ Status = pBS->LocateProtocol(&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gHiiString);
+ if(EFI_ERROR(Status))
+ return 0;
+ }
+
+ Status = gHiiString->GetLanguages(gHiiString, HiiHandle, Languages, &LangSize);
+ if(Status == EFI_BUFFER_TOO_SMALL) {
+ Status = pBS->AllocatePool(EfiBootServicesData, LangSize, &Languages);
+ if(EFI_ERROR(Status))
+ return NULL; //not enough resources to allocate string
+ Status = gHiiString->GetLanguages(gHiiString, HiiHandle, Languages, &LangSize);
+ }
+ if(EFI_ERROR(Status))
+ return 0;
+
+ OrgLanguages = Languages;
+ while(!LastLanguage) {
+ CHAR8* CurrentLanguage;
+
+ CurrentLanguage = Languages; //point CurrentLanguage to start of new language
+ while(*Languages != ';' && *Languages != 0)
+ Languages++;
+
+ StrSaveTemp = *Languages;
+ *Languages = 0; //put null-terminator
+ Size=0x100;
+ Status=gHiiString->GetString(gHiiString, CurrentLanguage, HiiHandle, STRING_TOKEN(STR_BOOT_OPTION), BootOptionStr, &Size, NULL);
+ *Languages = StrSaveTemp;
+ if( EFI_ERROR(Status) ) //Language not define in .uni
+ {
+ if(*Languages == 0) //last language in language list
+ LastLanguage = TRUE;
+ else
+ {
+ *Languages = ';'; //restore original character
+ Languages++;
+ }
+ continue;
+ }
+
+ Swprintf(BootStr, BootOptionStr, BootOptionNumber);
+
+ if(*Languages == 0) { //last language in language list
+ LastLanguage = TRUE;
+ if(StringId == 0)
+ Status = gHiiString->NewString(gHiiString, HiiHandle, &StringId, CurrentLanguage, NULL, BootStr, NULL);
+ else
+ Status = gHiiString->SetString(gHiiString, HiiHandle, StringId, CurrentLanguage, BootStr, NULL);
+ if(EFI_ERROR(Status))
+ {pBS->FreePool(OrgLanguages); return 0;}
+ } else {
+ *Languages = 0; //put null-terminator
+ if(StringId == 0)
+ Status = gHiiString->NewString(gHiiString, HiiHandle, &StringId, CurrentLanguage, NULL, BootStr, NULL);
+ else
+ Status = gHiiString->SetString(gHiiString, HiiHandle, StringId, CurrentLanguage, BootStr, NULL);
+ *Languages = ';'; //restore original character
+ Languages++;
+ if(EFI_ERROR(Status))
+ {pBS->FreePool(OrgLanguages); return 0;}
+ }
+ }
+
+ if( OrgLanguages )
+ pBS->FreePool(OrgLanguages);
+ return StringId;
+}
+ //<(EIP101408+)
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: InitialLegacyHiiItemDefault
+//
+// Description: Create legacy boot item device Hii Item data.
+//
+// Input:
+// EFI_HANDLE HiiHandle
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitialLegacyHiiItemDefault(EFI_HANDLE HiiHandle)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ EFI_HANDLE RegHandle = NULL;
+#endif
+ //<(EIP103171+)
+ UINTN DevOrderSize = 0;
+ UINT16 DevMapCount=0;
+ UINT16 VarSetupID, VarFixedBootID;
+ LEGACY_DEVICE_ORDER *DevOrder=NULL, *DevOrderBuffer=NULL;
+
+ DevMapCount = GetDevMapDataCount(pFBOLegacyDevMap);
+ TRACE((-1,"[FixedBootOrderTSE.c]HiiDevMap count=%d\n", DevMapCount ));
+
+ InitHiiData( HiiHandle );
+ VarSetupID = FIndVariableID( "Setup" );
+ TRACE((-1,"[FixedBootOrderTSE.c] Find Setup VarID=%02x\n", VarSetupID));
+ VarFixedBootID = FIndVariableID( "FixedBoot" );
+ TRACE((-1,"[FixedBootOrderTSE.c] Find FixedBoot VarID=%02x\n", VarFixedBootID));
+ FreeHiiData();
+
+ {
+ STRING_REF Strid=0;
+ EFI_HII_UPDATE_DATA Update;
+
+ if( gHiiString == NULL )
+ Status = pBS->LocateProtocol(&gEfiHiiStringProtocolGuid, NULL, &gHiiString);
+
+ if( pFBOHiiMap == NULL )
+ {
+ TRACE((-1,"pFBOHiiMap == NULL\n"));
+ ASSERT(pFBOHiiMap);
+ }
+
+ if(!EFI_ERROR(Status))
+ {
+ UINT8 *IfrTempPtr,*OldIfrTempPtr = NULL;
+ SETUP_DATA *pSetup=0;
+ UINT16 i,j;
+ HII_DEVICE_INFO *pHiiDevTokenData = NULL, *pHiiDevTokenData2 = NULL;
+
+ OldIfrTempPtr = IfrTempPtr = Malloc(
+ ( sizeof(EFI_IFR_ONE_OF)
+ +sizeof(EFI_IFR_ONE_OF_OPTION)*(DevMapCount+1) // include one disable option
+ +sizeof(EFI_IFR_END) )
+ *DevMapCount);
+ if (IfrTempPtr == NULL)
+ {
+ TRACE((-1, "Error allocation memory for creating IFR\n"));
+ ASSERT(IfrTempPtr);
+ }
+ Update.Data = IfrTempPtr;
+
+ for(i=0;i<DevMapCount;i++)
+ {
+ UINT16 HiiMapIndex;
+
+ if( pBootOptionTokenMap == NULL ) //(EIP123284+)
+ Strid = HiiAddLanguageBootOptionString(HiiHandle, i+1); //(EIP101408+)
+ else //(EIP123284+)
+ Strid = pBootOptionTokenMap[i]; //(EIP123284+)
+
+ Status = CreateHiiOneOfItem( &IfrTempPtr, VarSetupID, (UINT16)&pSetup->LegacyPriorities[i], LegacyBootItemKey+i, Strid, STR_BOOT_OPTION_HELP, 0x11);
+
+ for(j=0;j<DevMapCount;j++)
+ {
+
+ HiiMapIndex = SearchHiiMapByType( pFBOLegacyDevMap[j].DevType );
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 1, j, pFBOHiiMap[HiiMapIndex].StrToken );
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 1, DevMapCount, STR_DISABLED );
+#endif
+ CreateHiiIfrEndItem( &IfrTempPtr );
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ RegHandle = NULL;
+ if( AmiSetupProtocol != NULL )
+ AmiSetupProtocol->RegisterCallback(FBO_STRING_INIT_FORM_SET_CLASS, 0, LegacyBootItemKey+i, FixedBootOrderFormCallBack, &RegHandle);
+#endif
+ //<(EIP103171+)
+ }
+
+
+ Update.Offset = (UINT32)((UINT8*)IfrTempPtr-(UINT8*)Update.Data); //Calc Hii data length.
+ TRACE((-1,"Update.Data...............\n"));
+// TraceOutData( (UINT8*)Update.Data, Update.Offset );
+
+ Status = IfrLibUpdateForm (
+ HiiHandle,
+ NULL,
+ FBO_VFR_FORM_ID,
+ FIXED_BOOT_ITEM_LABEL1,
+ TRUE,
+ &Update);
+
+ TRACE((-1,"IfrLibUpdateForm (%r)\n", Status));
+ pBS->FreePool(OldIfrTempPtr);
+
+ OldIfrTempPtr = IfrTempPtr = Malloc(
+ ( sizeof(EFI_IFR_ONE_OF)
+ +sizeof(EFI_IFR_ONE_OF_OPTION)*(FIXED_BOOT_ORDER_SUBMENU_MAX_NUM+1) // include one disable option
+ +sizeof(EFI_IFR_END) )
+ *FIXED_BOOT_ORDER_SUBMENU_MAX_NUM);
+ if (IfrTempPtr == NULL)
+ {
+ TRACE((-1, "Error allocation memory for creating IFR\n"));
+ ASSERT(IfrTempPtr);
+ }
+
+ Status = GetEfiVariable( L"FboLegacyDevOrder", &FixedBootOrderGuid, NULL, &DevOrderSize, &DevOrderBuffer );
+ TRACE((-1,"GetEfiVariable(FboLegacyDevOrder) %r\n", Status));
+ if (EFI_ERROR(Status) || DevOrderSize<=6) return Status;
+
+ pHiiDevTokenData2 = pHiiDevTokenData = Malloc( DevOrderSize );
+ if( pHiiDevTokenData == NULL ) return EFI_OUT_OF_RESOURCES;
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+DevOrderSize
+ ;DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(UINT32)) )
+ {
+ UINT16 SubmenuIndex;
+
+ SubmenuIndex = SearchHiiMapByType( DevOrder->Type );
+ if( pFBOHiiMap[SubmenuIndex].FormID == 0 ) continue; //this type no Submenu
+
+ pHiiDevTokenData->Type=DevOrder->Type;
+ pHiiDevTokenData->Length=DevOrder->Length;
+
+ //Create BootOption item string token ID.
+ for(i=0;i<(DevOrder->Length-2)/sizeof(UINT16);i++)
+ {
+ if (i >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+ Status = gHiiString->NewString(gHiiString, HiiHandle, &Strid, Language, NULL, L" ", NULL);
+ if( EFI_ERROR(Status) )
+ return Status;
+ pHiiDevTokenData->StrToken[i]=Strid;
+ }
+
+ Update.Data = IfrTempPtr = OldIfrTempPtr; //reset IFR data memory.
+ for(i=0;i<(DevOrder->Length-2)/sizeof(UINT16);i++)
+ {
+ UINT16 VarOffset;
+ UINT16 CallBackKey;
+ UINT16 DevDataIndex=0;
+
+ if (i >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+ DevDataIndex = SearchDevMapByType( pFBOLegacyDevMap, pHiiDevTokenData->Type );
+ VarOffset=(DevDataIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) + i; //offset to FIXED_BOOT_SETUP.LegacyDevice[]
+ CallBackKey=(DevDataIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) + i + LegacyForms_StartKey;
+
+ if( pBootOptionTokenMap == NULL ) //(EIP123284+)
+ Strid = HiiAddLanguageBootOptionString(HiiHandle, i+1); //(EIP101408+)
+ else //(EIP123284+)
+ Strid = pBootOptionTokenMap[i]; //(EIP123284+)
+ Status = CreateHiiOneOfItem( &IfrTempPtr, VarFixedBootID, VarOffset, CallBackKey, Strid, STR_BOOT_OPTION_HELP, 0x10);
+
+ for(j=0;j<(pHiiDevTokenData->Length-2)/sizeof(UINT16);j++)
+ {
+ if (j >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+ if( pFBOHiiMap == NULL )
+ {
+ TRACE((-1,"pFBOHiiMap == NULL\n"));
+ ASSERT(pFBOHiiMap);
+ }
+
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 0, j, pHiiDevTokenData->StrToken[j] ); //UINT8
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ Status = CreateHiiOneOfOptionItem(&IfrTempPtr, 0, FIXED_BOOT_ORDER_SUBMENU_MAX_NUM, STR_DISABLED);
+#endif
+ CreateHiiIfrEndItem( &IfrTempPtr );
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ RegHandle = NULL;
+ if( AmiSetupProtocol != NULL )
+ AmiSetupProtocol->RegisterCallback(FBO_STRING_INIT_FORM_SET_CLASS, 0, CallBackKey, FixedBootOrderFormCallBack, &RegHandle);
+#endif
+ //<(EIP103171+)
+ }
+
+ Update.Offset = (UINT32)((UINT8*)IfrTempPtr-(UINT8*)Update.Data); //Calc Hii data length.
+ TRACE((-1,"Update.Data...............\n"));
+// TraceOutData( (UINT8*)Update.Data, Update.Offset );
+
+ Status = IfrLibUpdateForm (
+ HiiHandle,
+ NULL,
+ pFBOHiiMap[SubmenuIndex].FormID,
+ pFBOHiiMap[SubmenuIndex].Label,
+ TRUE,
+ &Update);
+
+ TRACE((-1,"IfrLibUpdateForm (%r)\n", Status));
+ pHiiDevTokenData = (HII_DEVICE_INFO*)((UINT8*)pHiiDevTokenData+pHiiDevTokenData->Length+sizeof(UINT32));
+
+ }
+ pBS->FreePool(OldIfrTempPtr);
+
+ {
+ UINT16 HiiDevInfoSize;
+ HiiDevInfoSize=(UINT16)((UINT8*)pHiiDevTokenData-(UINT8*)pHiiDevTokenData2);
+
+ if(HiiDevInfoSize)
+ {
+ pRS->SetVariable(
+ L"FixedHiiLegacyDevData",
+ &FixedBootOrderGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ HiiDevInfoSize,
+ pHiiDevTokenData2);
+ }
+ }
+ pBS->FreePool( pHiiDevTokenData2 );
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: InitialUefiHiiItemDefault
+//
+// Description: Create UEFI boot item device Hii Item data.
+//
+// Input:
+// EFI_HANDLE HiiHandle
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitialUefiHiiItemDefault(EFI_HANDLE HiiHandle)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ EFI_HANDLE RegHandle = NULL;
+#endif
+ //<(EIP103171+)
+ UINTN DevOrderSize = 0;
+ UINT16 DevMapCount=0;
+ UINT16 VarSetupID, VarFixedBootID;
+ LEGACY_DEVICE_ORDER *DevOrder=NULL, *DevOrderBuffer=NULL;
+
+ DevMapCount = GetDevMapDataCount(pFBOUefiDevMap);
+ TRACE((-1,"[FixedBootOrderTSE.c]HiiDevMap count=%d\n", DevMapCount ));
+
+ InitHiiData( HiiHandle );
+ VarSetupID = FIndVariableID( "Setup" );
+ TRACE((-1,"[FixedBootOrderTSE.c] Find Setup VarID=%02x\n", VarSetupID));
+ VarFixedBootID = FIndVariableID( "FixedBoot" );
+ TRACE((-1,"[FixedBootOrderTSE.c] Find FixedBoot VarID=%02x\n", VarFixedBootID));
+ FreeHiiData();
+
+ {
+ STRING_REF Strid=0;
+ EFI_HII_UPDATE_DATA Update;
+
+ if( gHiiString == NULL )
+ Status = pBS->LocateProtocol(&gEfiHiiStringProtocolGuid, NULL, &gHiiString);
+
+ if( pFBOHiiMap == NULL )
+ {
+ TRACE((-1,"pFBOHiiMap == NULL\n"));
+ ASSERT(pFBOHiiMap);
+ }
+
+ if(!EFI_ERROR(Status))
+ {
+ UINT8 *IfrTempPtr,*OldIfrTempPtr = NULL;
+ SETUP_DATA *pSetup=0;
+ UINT16 i,j;
+ HII_DEVICE_INFO *pHiiDevTokenData = NULL, *pHiiDevTokenData2 = NULL;
+
+ OldIfrTempPtr = IfrTempPtr = Malloc(
+ ( sizeof(EFI_IFR_ONE_OF)
+ +sizeof(EFI_IFR_ONE_OF_OPTION)*(DevMapCount+1) // include one disable option
+ +sizeof(EFI_IFR_END) )
+ *DevMapCount);
+ if (IfrTempPtr == NULL)
+ {
+ TRACE((-1, "Error allocation memory for IFR\n"));
+ ASSERT(IfrTempPtr);
+ }
+ Update.Data = IfrTempPtr;
+
+ for(i=0;i<DevMapCount;i++)
+ {
+ UINT16 HiiMapIndex;
+
+ if( pBootOptionTokenMap == NULL ) //(EIP123284+)
+ Strid = HiiAddLanguageBootOptionString(HiiHandle, i+1); //(EIP101408+)
+ else //(EIP123284+)
+ Strid = pBootOptionTokenMap[i]; //(EIP123284+)
+ Status = CreateHiiOneOfItem( &IfrTempPtr, VarSetupID, (UINT16)&pSetup->UefiPriorities[i], UefiBootItemKey+i, Strid, STR_BOOT_OPTION_HELP, 0x11);
+
+ for(j=0;j<DevMapCount;j++)
+ {
+
+ HiiMapIndex = SearchHiiMapByType( pFBOUefiDevMap[j].DevType );
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 1, j, pFBOHiiMap[HiiMapIndex].StrToken );
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 1, DevMapCount, STR_DISABLED );
+#endif
+ CreateHiiIfrEndItem( &IfrTempPtr );
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ RegHandle = NULL;
+ if( AmiSetupProtocol != NULL )
+ AmiSetupProtocol->RegisterCallback(FBO_STRING_INIT_FORM_SET_CLASS, 0, UefiBootItemKey+i, FixedBootOrderFormCallBack, &RegHandle);
+#endif
+ //<(EIP103171+)
+ }
+
+ Update.Offset = (UINT32)((UINT8*)IfrTempPtr-(UINT8*)Update.Data); //Calc Hii data length.
+ TRACE((-1,"Update.Data...............\n"));
+// TraceOutData( (UINT8*)Update.Data, Update.Offset );
+
+ Status = IfrLibUpdateForm (
+ HiiHandle,
+ NULL,
+ FBO_VFR_FORM_ID,
+ FIXED_BOOT_ITEM_LABEL2,
+ TRUE,
+ &Update);
+
+ TRACE((-1,"IfrLibUpdateForm (%r)\n", Status));
+ pBS->FreePool(OldIfrTempPtr);
+
+ OldIfrTempPtr = IfrTempPtr = Malloc(
+ ( sizeof(EFI_IFR_ONE_OF)
+ +sizeof(EFI_IFR_ONE_OF_OPTION)*(FIXED_BOOT_ORDER_SUBMENU_MAX_NUM+1) // include one disable option
+ +sizeof(EFI_IFR_END) )
+ *FIXED_BOOT_ORDER_SUBMENU_MAX_NUM);
+ if (IfrTempPtr == NULL)
+ {
+ TRACE((-1, "Error allocation memory for creating IFR\n"));
+ ASSERT(IfrTempPtr);
+ }
+
+ //Create submenu boot item.
+ Status = GetEfiVariable( L"UefiDevOrder", &FixedBootOrderGuid, NULL, &DevOrderSize, &DevOrderBuffer );
+ TRACE((-1,"GetEfiVariable(UefiDevOrder) %r\n", Status));
+ if (EFI_ERROR(Status) || DevOrderSize<=6) return Status;
+
+ pHiiDevTokenData2 = pHiiDevTokenData = Malloc( DevOrderSize );
+ if( pHiiDevTokenData == NULL ) return EFI_OUT_OF_RESOURCES;
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+DevOrderSize
+ ;DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(UINT32)) )
+ {
+ UINT16 SubmenuIndex;
+
+ SubmenuIndex = SearchHiiMapByType( DevOrder->Type );
+ if( pFBOHiiMap[SubmenuIndex].FormID == 0 ) continue; //this type no Submenu
+
+ pHiiDevTokenData->Type=DevOrder->Type;
+ pHiiDevTokenData->Length=DevOrder->Length;
+
+ //Create BootOption item string token ID.
+ for(i=0;i<(DevOrder->Length-2)/sizeof(UINT16);i++)
+ {
+ if (i >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+ Status = gHiiString->NewString(gHiiString, HiiHandle, &Strid, Language, NULL, L" ", NULL);
+ if( EFI_ERROR(Status) )
+ return Status;
+ pHiiDevTokenData->StrToken[i]=Strid;
+ }
+
+
+ Update.Data = IfrTempPtr = OldIfrTempPtr; //reset IFR data memory.
+
+ for(i=0;i<(pHiiDevTokenData->Length-2)/sizeof(UINT16);i++)
+ {
+ UINT16 VarOffset;
+ UINT16 CallBackKey;
+ UINT16 DevDataIndex=0;
+
+ if (i >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+ DevDataIndex = SearchDevMapByType( pFBOUefiDevMap, pHiiDevTokenData->Type );
+ VarOffset = (DevDataIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) + EFI_FIELD_OFFSET(FIXED_BOOT_SETUP, UefiDevice) + i; //offset to FIXED_BOOT_SETUP.UefiDevice[]
+ CallBackKey=(DevDataIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) + i +UefiForms_StartKey; //
+
+ if( pBootOptionTokenMap == NULL ) //(EIP123284+)
+ Strid = HiiAddLanguageBootOptionString(HiiHandle, i+1); //(EIP101408+)
+ else //(EIP123284+)
+ Strid = pBootOptionTokenMap[i]; //(EIP123284+)
+ Status = CreateHiiOneOfItem( &IfrTempPtr, VarFixedBootID, VarOffset, CallBackKey, Strid, STR_BOOT_OPTION_HELP, 0x10);
+
+ for(j=0;j<(pHiiDevTokenData->Length-2)/sizeof(UINT16);j++)
+ {
+ if (j >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+ if( pFBOHiiMap == NULL )
+ {
+ TRACE((-1,"pFBOHiiMap == NULL\n"));
+ ASSERT(pFBOHiiMap);
+ }
+
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 0, j, pHiiDevTokenData->StrToken[j] ); //UINT8
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 0, FIXED_BOOT_ORDER_SUBMENU_MAX_NUM, STR_DISABLED );
+#endif
+ CreateHiiIfrEndItem( &IfrTempPtr );
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ RegHandle = NULL;
+ if( AmiSetupProtocol != NULL )
+ AmiSetupProtocol->RegisterCallback(FBO_STRING_INIT_FORM_SET_CLASS, 0, CallBackKey, FixedBootOrderFormCallBack, &RegHandle);
+#endif
+ //<(EIP103171+)
+ }
+
+ Update.Offset = (UINT32)((UINT8*)IfrTempPtr-(UINT8*)Update.Data); //Calc Hii data length.
+ TRACE((-1,"Update.Data...............\n"));
+// TraceOutData( (UINT8*)Update.Data, Update.Offset );
+
+ Status = IfrLibUpdateForm (
+ HiiHandle,
+ NULL,
+ pFBOHiiMap[SubmenuIndex].FormID,
+ pFBOHiiMap[SubmenuIndex].Label,
+ TRUE,
+ &Update);
+
+ TRACE((-1,"IfrLibUpdateForm (%r)\n", Status));
+ pHiiDevTokenData = (HII_DEVICE_INFO*)((UINT8*)pHiiDevTokenData+pHiiDevTokenData->Length+sizeof(UINT32));
+ }
+ pBS->FreePool(OldIfrTempPtr);
+
+ {
+ UINT16 HiiDevInfoSize;
+ HiiDevInfoSize=(UINT16)((UINT8*)pHiiDevTokenData-(UINT8*)pHiiDevTokenData2);
+
+ if(HiiDevInfoSize)
+ {
+ pRS->SetVariable(
+ L"FixedHiiUefiDevData",
+ &FixedBootOrderGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ HiiDevInfoSize,
+ pHiiDevTokenData2);
+ }
+ }
+
+ pBS->FreePool( pHiiDevTokenData2 );
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+#if FBO_DUAL_MODE
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: InitialDaulHiiItem
+//
+// Description: Create Dual mode boot item device Hii Item data.
+//
+// Input:
+// EFI_HANDLE HiiHandle
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitialDaulHiiItem(EFI_HANDLE HiiHandle)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ EFI_HANDLE RegHandle = NULL;
+#endif
+ //<(EIP103171+)
+ UINT16 DevMapCount=0;
+ UINT16 VarSetupID, VarFixedBootID;
+
+
+ DevMapCount = GetDevMapDataCount(pFBODualDevMap);
+ TRACE((-1,"[FixedBootOrderTSE.c]HiiDevMap count=%d\n", DevMapCount ));
+
+ InitHiiData( HiiHandle );
+ VarSetupID = FIndVariableID( "Setup" );
+ TRACE((-1,"[FixedBootOrderTSE.c] Find Setup VarID=%02x\n", VarSetupID));
+ VarFixedBootID = FIndVariableID( "FixedBoot" );
+ TRACE((-1,"[FixedBootOrderTSE.c] Find FixedBoot VarID=%02x\n", VarFixedBootID));
+ FreeHiiData();
+
+ {
+ STRING_REF Strid=0;
+ EFI_HII_UPDATE_DATA Update;
+
+ if( gHiiString == NULL )
+ Status = pBS->LocateProtocol(&gEfiHiiStringProtocolGuid, NULL, &gHiiString);
+
+ if( pFBOHiiMap == NULL )
+ {
+ TRACE((-1,"pFBOHiiMap == NULL\n"));
+ ASSERT(pFBOHiiMap);
+ }
+
+ if(!EFI_ERROR(Status))
+ {
+ UINT8 *IfrTempPtr,*OldIfrTempPtr = NULL;
+ SETUP_DATA *pSetup=0;
+ UINT16 i,j;
+
+ OldIfrTempPtr = IfrTempPtr = Malloc(
+ ( sizeof(EFI_IFR_ONE_OF)
+ +sizeof(EFI_IFR_ONE_OF_OPTION)*(DevMapCount+1) // include one disable option
+ +sizeof(EFI_IFR_END) )
+ *DevMapCount);
+ if (IfrTempPtr == NULL)
+ {
+ TRACE((FBO_TRACE_LEVEL, "Error allocation memory for IFR\n"));
+ ASSERT(IfrTempPtr);
+ }
+ Update.Data = IfrTempPtr;
+
+ for(i=0;i<DevMapCount;i++)
+ {
+ UINT16 HiiMapIndex;
+
+ if( pBootOptionTokenMap == NULL ) //(EIP123284+)
+ Strid = HiiAddLanguageBootOptionString(HiiHandle, i+1); //(EIP101408+)
+ else //(EIP123284+)
+ Strid = pBootOptionTokenMap[i]; //(EIP123284+)
+ Status = CreateHiiOneOfItem( &IfrTempPtr, VarSetupID, (UINT16)&pSetup->DualPriorities[i], DualBootItemKey+i, Strid, STR_BOOT_OPTION_HELP, 0x11);
+
+ for(j=0;j<DevMapCount;j++)
+ {
+
+ HiiMapIndex = SearchHiiMapByType( pFBODualDevMap[j].DevType );
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 1, j, pFBOHiiMap[HiiMapIndex].StrToken );
+ }
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ Status = CreateHiiOneOfOptionItem( &IfrTempPtr, 1, DevMapCount, STR_DISABLED );
+#endif
+ CreateHiiIfrEndItem( &IfrTempPtr );
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ RegHandle = NULL;
+ if( AmiSetupProtocol != NULL )
+ AmiSetupProtocol->RegisterCallback(FBO_STRING_INIT_FORM_SET_CLASS, 0, DualBootItemKey+i, FixedBootOrderFormCallBack, &RegHandle);
+#endif
+ //<(EIP103171+)
+ }
+
+ Update.Offset = (UINT32)((UINT8*)IfrTempPtr-(UINT8*)Update.Data); //Calc Hii data length.
+ TRACE((-1,"Update.Data...............\n"));
+// TraceOutData( (UINT8*)Update.Data, Update.Offset );
+
+ Status = IfrLibUpdateForm (
+ HiiHandle,
+ NULL,
+ FBO_VFR_FORM_ID,
+ FIXED_BOOT_ITEM_LABEL3,
+ TRUE,
+ &Update);
+
+ TRACE((-1,"IfrLibUpdateForm (%r)\n", Status));
+
+ pBS->FreePool( OldIfrTempPtr );
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+#endif
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: load_default_string
+//
+// Description: This function called after setup utility loaded config defaults
+// based on user input. change fixedbootorder display default
+// devcie string.
+//
+// Input:
+//
+// Output:
+// EFI_STATUS
+//
+// Modified:
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS load_default_string()
+{
+ TRACE((-1,"[FixedBootOrder.c]Load Default String\n"));
+ LoadedDefault=TRUE; //TRUE = Load default
+ //Initial Legacy Device HiiString name.
+ InitLegacyGroup();
+ //Initial Uefi Device HiiString.
+ InitUefiGroup();
+
+ return EFI_SUCCESS;
+}
+
+static EFI_FIXED_BOOT_ORDER_SETUP_PROTOCOL gFixedBootOrderSetupProtocol =
+{
+ load_default_string
+};
+
+
+VOID SetVarDefaults(CHAR16 *VarNames, UINT8 *pFixedBootGroup)
+{
+ EFI_STATUS Status;
+ UINT16 i, j;
+ UINT32 Attr;
+ UINTN Size = 0, NameSize;
+ EFI_GUID DefaultsGuid = DEFAULTS_GUID;
+ NVAR *pDefaultsBuffer = NULL, *pNVAR;
+ NVRAM_STORE_INFO NvStore;
+ EFI_GUID gSetupGuid = SETUP_GUID;
+ SETUP_DATA *StdSetupData;
+ FIXED_BOOT_SETUP *FixedBootSetup;
+ FIXED_BOOT_GROUP *StdFixedBootGroup;
+ UINT8* p;
+ BOOLEAN Update = FALSE;
+ static BOOLEAN SetupOnce = FALSE;
+
+ //Update variable Defaults data, use for load default.
+ Status = GetEfiVariable(VarNames, &DefaultsGuid, &Attr, &Size, &pDefaultsBuffer);
+ TRACE((-1, "[FixedBootOrder.c] GetEfiVariable(%S) %r\n", VarNames, Status));
+ if(EFI_ERROR(Status))
+ return;
+
+ NvStore.NvramAddress = (UINT8*)pDefaultsBuffer;
+ NvStore.NvramSize = Size;
+ NvInitInfoBuffer(
+ &NvStore,
+ 0,
+ NVRAM_STORE_FLAG_NON_VALATILE
+ );
+
+ if(!SetupOnce)
+ {
+ pNVAR = (NVAR*)NvFindVariable(L"Setup",&gSetupGuid,&NameSize,&NvStore);
+ if(pNVAR)
+ {
+ UINT16 DevCount = 0;
+ SetupOnce = TRUE;
+ StdSetupData = (SETUP_DATA*)NvGetData(pNVAR, NameSize, &Size, &NvStore);
+ //(EIP107268+)>
+#if USE_BCP_DEFAULT_PRIORITIES
+ DevCount = GetDevMapDataCount(pFBOUefiDevMap);
+ for (i = 0; i < DevCount; i++)
+ StdSetupData->UefiPriorities[i] = StdSetupData->BcpDefaultUefiPriorities[i]; //(EIP115686+)
+
+ DevCount = GetDevMapDataCount(pFBOLegacyDevMap);
+ for (i = 0; i < DevCount; i++)
+ StdSetupData->LegacyPriorities[i] = StdSetupData->BcpDefaultLegacyPriorities[i]; //(EIP115686+)
+ //(EIP122146+)>
+#if FBO_DUAL_MODE
+ DevCount = GetDevMapDataCount(pFBODualDevMap);
+ for (i = 0; i < DevCount; i++)
+ StdSetupData->DualPriorities[i] = StdSetupData->BcpDefaultDualPriorities[i];
+#endif
+ //<(EIP122146+)
+#else //<(EIP107268+)
+ DevCount = GetDevMapDataCount(pFBOUefiDevMap);
+ for (i = 0; i < DevCount; i++)
+ StdSetupData->UefiPriorities[i] = (UINT16)i;
+
+ DevCount = GetDevMapDataCount(pFBOLegacyDevMap);
+ for (i = 0; i < DevCount; i++)
+ StdSetupData->LegacyPriorities[i] = (UINT16)i;
+#if FBO_DUAL_MODE
+ DevCount = GetDevMapDataCount(pFBODualDevMap);
+ for (i = 0; i < DevCount; i++)
+ StdSetupData->DualPriorities[i] = (UINT16)i;
+#endif
+
+#endif //#if USE_BCP_DEFAULT_PRIORITIES //(EIP107268+)
+ Update = TRUE;
+
+ // It's hard code in NVRam Driver, so we just hard code here.
+ if ( (pNVAR->flags & NVRAM_FLAG_EXT_HEDER)
+ && (*NvGetExtFlags(pNVAR) & NVRAM_EXT_FLAG_CHECKSUM) )
+ {
+ p = ((UINT8*)pNVAR) + pNVAR->size - 3;
+ // Set CheckSum to 0 them Calculate it
+ *p = 0;
+ *p = NvCalculateNvarChecksum(pNVAR);
+ }
+ }
+ }
+
+ pNVAR = (NVAR*)NvFindVariable(L"FixedBoot",&gSetupGuid,&NameSize,&NvStore);
+ if(pNVAR)
+ {
+ FixedBootSetup = (FIXED_BOOT_SETUP*)NvGetData(pNVAR, NameSize, &Size, &NvStore);
+ for (i = 0; i < FIXED_BOOT_ORDER_GROUP_MAX_NUM; i++)
+ for (j = 0; j < FIXED_BOOT_ORDER_SUBMENU_MAX_NUM; j++)
+ FixedBootSetup->LegacyDevice[(i*FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)+j] = (UINT8)j;
+ for (i = 0; i < FIXED_BOOT_ORDER_GROUP_MAX_NUM; i++)
+ for (j = 0; j < FIXED_BOOT_ORDER_SUBMENU_MAX_NUM; j++)
+ FixedBootSetup->UefiDevice[(i*FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)+j] = (UINT8)j;
+
+ Update = TRUE;
+
+ if ( (pNVAR->flags & NVRAM_FLAG_EXT_HEDER)
+ && (*NvGetExtFlags(pNVAR) & NVRAM_EXT_FLAG_CHECKSUM) )
+ {
+ // It's hard code in NVRam Driver, so we just hard code here.
+ p = ((UINT8*)pNVAR) + pNVAR->size - 3;
+ // Set CheckSum to 0 them Calculate it
+ *p = 0;
+ *p = NvCalculateNvarChecksum(pNVAR);
+ }
+ }
+
+ pNVAR = (NVAR*)NvFindVariable(L"FixedBootGroup",&gSetupGuid,&NameSize,&NvStore);
+ if(pNVAR)
+ {
+ StdFixedBootGroup = (FIXED_BOOT_GROUP*)NvGetData(pNVAR, NameSize, &Size, &NvStore);
+ pBS->CopyMem(StdFixedBootGroup, pFixedBootGroup, sizeof(FIXED_BOOT_GROUP));
+ Update = TRUE;
+
+ if ( (pNVAR->flags & NVRAM_FLAG_EXT_HEDER)
+ && (*NvGetExtFlags(pNVAR) & NVRAM_EXT_FLAG_CHECKSUM) )
+ {
+ // It's hard code in NVRam Driver, so we just hard code here.
+ p = ((UINT8*)pNVAR) + pNVAR->size - 3;
+ // Set CheckSum to 0 them Calculate it
+ *p = 0;
+ *p = NvCalculateNvarChecksum(pNVAR);
+ }
+ }
+
+ if (Update)
+ {
+ pRS->SetVariable(VarNames,
+ &DefaultsGuid,
+ Attr,
+ NvStore.NvramSize,
+ pDefaultsBuffer);
+ }
+
+ pBS->FreePool(pDefaultsBuffer);
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FixedBootOrderStringInit
+//
+// Description: Install a form callback.
+//
+// Input:
+// IN EFI_HII_HANDLE HiiHandle
+// IN UINT16 Class
+//
+// Output:
+//
+// Modified:
+//
+// Referrals: SetupStringInit
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FixedBootOrderStringInit(
+ IN EFI_HII_HANDLE HiiHandle,
+ IN UINT16 Class
+)
+{
+#if CSM_SUPPORT
+EFI_GUID gEfiLegacyBiosProtocolGuid = EFI_LEGACY_BIOS_PROTOCOL_GUID;
+EFI_LEGACY_BIOS_PROTOCOL *LegacyBios=NULL;
+#endif
+EFI_GUID gSetupGuid = SETUP_GUID;
+EFI_STATUS Status = EFI_SUCCESS;
+EFI_FIXED_BOOT_ORDER_PROTOCOL *pFBO=NULL;
+FIXED_BOOT_GROUP FixedBootGroup;
+UINT8 *pFixedBootGroup = (UINT8*)&FixedBootGroup;
+UINT8 i,j;
+
+ if (Class != FBO_STRING_INIT_FORM_SET_CLASS) return EFI_SUCCESS;
+
+ pRS->SetVariable(
+ L"FixedBootOrderHii",
+ &FixedBootOrderGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(EFI_HII_HANDLE),
+ &HiiHandle);
+
+ TRACE((-1,"FixedBootOrderStringInit HiiHanlde = %x\n", HiiHandle));
+ FixedBoot_HiiHandle = HiiHandle;
+
+#if CSM_SUPPORT
+ Status = pBS->LocateProtocol( &gEfiLegacyBiosProtocolGuid, NULL, &LegacyBios );
+ if(!EFI_ERROR(Status))
+ {
+
+ Status = LegacyBios->GetBbsInfo(LegacyBios, &HddCount, &HddInfo, &BbsCount, &BbsTable);
+ if(EFI_ERROR(Status)) return Status;
+
+ BbsDeviceName = MallocZ(BbsCount * (BBS_DEVICE_NAME_LENGTH+1));
+
+ if( BbsDeviceName != NULL )
+ {
+ for(i=0; i<BbsCount ;i++)
+ {
+ UINT8 *BBSNamePtr = NULL;
+
+ if( BbsTable[i].BootPriority == BBS_IGNORE_ENTRY ) continue;
+
+ BBSNamePtr = (UINT8*)( ((UINTN)BbsTable[i].DescStringSegment << 4)
+ + BbsTable[i].DescStringOffset );
+
+ if( BBSNamePtr != NULL )
+ pBS->CopyMem( &BbsDeviceName[i*(BBS_DEVICE_NAME_LENGTH+1)], BBSNamePtr, BBS_DEVICE_NAME_LENGTH);
+ }
+ }
+ }
+#endif
+ Status = pBS->LocateProtocol( &FixedBootOrderGuid, NULL, &pFBO );
+ if(!EFI_ERROR(Status))
+ {
+ pFBOLegacyDevMap = pFBO->GetLegacyDevMap();
+ pFBOUefiDevMap = pFBO->GetUefiDevMap();
+ pFBODualDevMap = pFBO->GetDualDevMap();
+ pFBOHiiMap = pFBO->GetHiiMap();
+ FBO_AdjustGroupName() ;
+ //(EIP123284+)>
+#if FBO_USE_BOOT_OPTION_NUMBER_UNI
+ pBootOptionTokenMap = pFBO->GetBootOptionTokenMap();
+#else
+ pBootOptionTokenMap = NULL;
+#endif
+ //<(EIP123284+)
+ }
+
+ pBS->SetMem( TypeLegacyDeviceCount, sizeof(TypeLegacyDeviceCount), 0);
+ pBS->SetMem( TypeUefiDeviceCount, sizeof(TypeUefiDeviceCount), 0);
+ pBS->SetMem( &FixedBootGroup, sizeof(FIXED_BOOT_GROUP), 0);
+ //(EIP103171+)>
+#if CORE_COMBINED_VERSION>=0x4028e
+ Status = pBS->LocateProtocol(&AmiSetupProtocolGuid, NULL, &AmiSetupProtocol);
+#endif
+ //<(EIP103171+)
+ InitialLegacyHiiItem(HiiHandle);
+ InitialUefiHiiItem(HiiHandle);
+#if FBO_DUAL_MODE
+ InitialDaulHiiItem(HiiHandle);
+#endif
+ //Initial Legacy Device HiiString name.
+ InitLegacyGroup();
+ //Initial Uefi Device HiiString.
+ InitUefiGroup();
+
+ {
+ EFI_HANDLE Handle = NULL;
+ EFI_GUID FixedBootOrderSetupGuid = FIXED_BOOT_ORDER_SETUP_GUID;
+
+ Status = pBS->InstallProtocolInterface (
+ &Handle,
+ &FixedBootOrderSetupGuid,
+ EFI_NATIVE_INTERFACE,
+ &gFixedBootOrderSetupProtocol);
+ }
+
+ //Set all types device count and set variable FixedBootGroup.
+ {
+ UINT16 DevMapCount;
+ UINT16 HiiDevIndex;
+ UINT16 DeviceCountOffset;
+
+
+ DevMapCount = GetDevMapDataCount(pFBOLegacyDevMap);
+ for(i=0;i<DevMapCount;i++)
+ {
+ HiiDevIndex = SearchHiiMapByType(pFBOLegacyDevMap[i].DevType);
+ if(pFBOHiiMap[HiiDevIndex].FormID == 0) continue; //no group submenu
+ DeviceCountOffset = pFBOHiiMap[HiiDevIndex].DeviceCountOffset;
+ pFixedBootGroup[DeviceCountOffset]=TypeLegacyDeviceCount[i];
+ }
+
+ DevMapCount = GetDevMapDataCount(pFBOUefiDevMap);
+ for(i=0;i<DevMapCount;i++)
+ {
+ HiiDevIndex = SearchHiiMapByType(pFBOUefiDevMap[i].DevType);
+ if(pFBOHiiMap[HiiDevIndex].FormID == 0) continue; //no group submenu
+ DeviceCountOffset = pFBOHiiMap[HiiDevIndex].DeviceCountOffset;
+ pFixedBootGroup[DeviceCountOffset]=TypeUefiDeviceCount[i];
+ }
+
+ pRS->SetVariable(
+ L"FixedBootGroup",
+ &gSetupGuid,
+ BS_NV_VARIABLE_ATTRIBUTES,
+ sizeof(FIXED_BOOT_GROUP),
+ &FixedBootGroup);
+
+ SetVarDefaults(L"StdDefaults",pFixedBootGroup);
+ SetVarDefaults(L"MfgDefaults",pFixedBootGroup);
+ }
+
+ //Initial ALL "FixedBoot" data.
+ {
+ EFI_GUID gSetupGuid = SETUP_GUID;
+ FIXED_BOOT_SETUP pFixedBoot;
+
+ for (i = 0; i < FIXED_BOOT_ORDER_GROUP_MAX_NUM; i++)
+ for (j = 0; j < FIXED_BOOT_ORDER_SUBMENU_MAX_NUM; j++)
+ pFixedBoot.LegacyDevice[(i*FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)+j] = TypeLegacyDeviceOptions[i][j];
+ for (i = 0; i < FIXED_BOOT_ORDER_GROUP_MAX_NUM; i++)
+ for (j = 0; j < FIXED_BOOT_ORDER_SUBMENU_MAX_NUM; j++)
+ pFixedBoot.UefiDevice[(i*FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)+j] = TypeUefiDeviceOptions[i][j];
+
+ Status = pRS->SetVariable(L"FixedBoot",
+ &gSetupGuid,
+ BS_NV_VARIABLE_ATTRIBUTES,
+ sizeof(pFixedBoot),
+ &pFixedBoot);
+ }
+ return Status;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Board/EM/FixedBootOrder/FixedBootOrder.chm b/Board/EM/FixedBootOrder/FixedBootOrder.chm
new file mode 100644
index 0000000..54cd3df
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrder.chm
Binary files differ
diff --git a/Board/EM/FixedBootOrder/FixedBootOrder.h b/Board/EM/FixedBootOrder/FixedBootOrder.h
new file mode 100644
index 0000000..9aeb6c0
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrder.h
@@ -0,0 +1,309 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+//*****************************************************************//
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrder.h $
+//
+// $Author: Dukeyeh $
+//
+// $Revision: 11 $
+//
+// $Date: 9/09/14 3:36a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrder.h $
+//
+// 11 9/09/14 3:36a Dukeyeh
+// [TAG] EIP171752
+// [Category] Improvement
+// [Description] Add FIXED_BOOT_ORDER_SUBMENU_MAX_NUM and
+// FIXED_BOOT_ORDER_GROUP_MAX_NUM tokens to decide maximum number of
+// submenus and groups at boot time.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+//
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 10 8/13/14 11:19p Walonli
+// [TAG] EIP180632
+// [Category] New Feature
+// [Description] Add FixedBootOrder Protocol to change device/group
+// name.
+// [Files] Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// FixedBootOrder.cif
+//
+// 9 5/20/14 3:48a Klzhan
+// [TAG] EIP167196
+// [Category] Improvement
+// [Description] Runtime attribute set for the some of the variable used
+// by FixedBootOrder needs to be reviewed.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 8 4/15/14 2:26a Klzhan
+// [TAG] EIP143078
+// [Category] Improvement
+// [Description] Set LOAD_OPTION_ACTIVE must be 0 when
+// LOAD_OPTION_HIDDEN=1
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 7 5/31/13 1:46a Easonchen
+// EIP123284
+// Set Boot Priority unicode string
+//
+// 6 10/04/12 2:15a Easonchen
+// [TAG] EIP96232
+// [Category] Improvement
+// [Description] Support USB Floppy in UEFI mode
+//
+// 5 6/28/12 11:22a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+// functionality.
+//
+// 2 12/06/28 11:04p Readwrite
+//
+// 2 12/06/28 10:41p Readwrite
+//
+// 4 4/14/11 4:00a Easonchen
+// [TAG] EIP35562
+// [Category] Improvement
+// [Description] In Core 4.6.4.1 or Last, Fixed boot variable name - hex
+// digits should be in upper case
+//
+//
+// 3 11/12/10 3:46a Easonchen
+// n TAG: EIP22689
+// TAG: EIP22689
+// Improvement: Support submenu function.
+//
+// 2 9/14/10 2:41a Easonchen
+//
+// 1 4/15/09 3:35a Jameswang
+//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//**********************************************************************
+//
+// Name: FixedBootOrder.h
+//
+// Description: Header file of FixedBootOrder module
+//
+//**********************************************************************
+//<AMI_FHDR_END>
+
+
+#ifndef _FIXED_BOOT_ORDER_H
+#define _FIXED_BOOT_ORDER_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef VFRCOMPILE
+
+#define FIXED_BOOT_ORDER_GUID \
+ {0xc923ca9, 0xdf73, 0x4ac8, 0xb6, 0xd2, 0x98, 0xdd, 0xc3, 0xd, 0x99, 0xfc}
+
+#define FIXED_BOOT_ORDER_SETUP_GUID \
+ {0x7e07911a, 0x4807, 0x4b0f, 0xa4, 0x74, 0xf5, 0x43, 0x1c, 0xa9, 0x07, 0xb4}
+
+#define DEFAULTS_GUID \
+ {0x4599d26f, 0x1a11, 0x49b8, 0xb9, 0x1f, 0x85, 0x87, 0x45, 0xcf, 0xf8, 0x24}
+
+#define DEFAULT_LEGACY_DEV_ORDER_VARIABLE_GUID \
+ { 0x3c4ead08, 0x45ae, 0x4315, 0x8d, 0x15, 0xa6, 0x0e, 0xaa, 0x8c, 0xaf, 0x69 }
+
+#define VARIABLE_ATTRIBUTES \
+ (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
+
+#define BS_NV_VARIABLE_ATTRIBUTES \
+ (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
+
+#pragma pack(1)
+
+typedef struct _FBODevMap {
+ UINT16 DevType;
+ UINT16 BBSType;
+ UINT16 Port;
+ UINT8 Attr;
+}FBODevMap;
+
+typedef struct _FBOHiiMap {
+ UINT16 DevType;
+ UINT16 StrToken;
+ UINT16 FormID;
+ UINT16 Label;
+ UINT16 DeviceCountOffset;
+}FBOHiiMap;
+
+typedef struct{
+ UINT32 Type;
+ UINT16 Length;
+ UINT16 StrToken[1];
+}HII_DEVICE_INFO;
+
+typedef struct{
+ UINT32 Type;
+ UINT16 Length;
+ UINT16 Device[1];
+}UEFI_DEVICE_ORDER;
+
+typedef struct _FBO_DEVICE_INFORM {
+ CHAR16 *DevName;
+ UINT16 DevType ;
+ UINT16 DevPortNum ;
+ UINT32 DevBDF ;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ struct _FBO_DEVICE_INFORM *Next ;
+} FBO_DEVICE_INFORM ;
+
+typedef struct _FBO_GROUP_OPTION {
+ UINT16 StrToken;
+ CHAR16 *OrgGroupName ;
+ CHAR16 *NewGroupName ;
+ struct _FBO_GROUP_OPTION *Next ;
+} FBO_GROUP_OPTION ;
+
+#pragma pack()
+//FBO Attr
+//#define TYPES_ALWAYS_PRESENT 0x01
+#define F_USB 0x02
+#define F_USBKEY 0x04
+
+#define FixedBootOrderStratKey 0x1000
+#define LegacyBootItemKey FixedBootOrderStratKey
+#define UefiBootItemKey (FixedBootOrderStratKey+0x80)
+#define DualBootItemKey (FixedBootOrderStratKey+0x100)
+#define LegacyForms_StartKey (FixedBootOrderStratKey+0x200)
+#define UefiForms_StartKey (FixedBootOrderStratKey+0x800)
+
+#if CORE_COMBINED_VERSION > 0x40280 //4.6.4.1 or Last
+#define gBootName L"Boot%04X"
+#else
+#define gBootName L"Boot%04x"
+#endif
+
+// Calculate the number of orders in this group (DevOrder->Type)
+#define DEVORDER_COUNT(DevOrder) (DevOrder->Length - sizeof(DevOrder->Length)) / sizeof(DevOrder->Device)
+
+#define FBO_LEGACY_DISABLED_MASK 0xff00 // LegacyDevOrder disabled flag mask
+#define FBO_LEGACY_ORDER_MASK 0x00ff // LegacyDevOrder valid BBS index mask
+#define FBO_UEFI_DISABLED_MASK 0xff000000 // UefiDevOrder disabled flag mask
+#define FBO_UEFI_ORDER_MASK 0x0000ffff // UefiDevOrde valid Boot number mask
+
+typedef EFI_STATUS (EFIAPI *LOAD_DEFAULT_STRING)();
+
+typedef struct _EFI_FIXED_BOOT_ORDER_SETUP_PROTOCOL {
+ LOAD_DEFAULT_STRING load_default_string;
+} EFI_FIXED_BOOT_ORDER_SETUP_PROTOCOL;
+
+
+typedef EFI_STATUS (EFIAPI *FBOSetDevMap)(IN FBODevMap *p);
+typedef EFI_STATUS (EFIAPI *FBOSetHiiMap)(IN FBOHiiMap *p);
+typedef FBODevMap *(EFIAPI *FBOGetDevMap)(IN VOID);
+typedef FBOHiiMap *(EFIAPI *FBOGetHiiMap)(IN VOID);
+typedef EFI_STATUS (EFIAPI *FBOSetBootOptionTokenMap)(IN UINT16 *p); //(EIP123284+)
+typedef UINT16 *(EFIAPI *FBOGetBootOptionTokenMap)(IN VOID); //(EIP123284+)
+typedef EFI_STATUS (EFIAPI *FBOSetNewDescription)(IN FBO_DEVICE_INFORM *p);
+typedef FBO_DEVICE_INFORM* (EFIAPI *FBOGetNewDescription)(IN VOID);
+
+
+typedef struct _EFI_FIXED_BOOT_ORDER_PROTOCOL {
+ FBOSetDevMap SetLegacyDevMap;
+ FBOSetDevMap SetUefiDevMap;
+ FBOSetDevMap SetDualDevMap;
+ FBOSetHiiMap SetHiiMap;
+ FBOSetBootOptionTokenMap SetBootOptionTokenMap; //(EIP123284+)
+ FBOSetNewDescription SetNewDescription;
+ FBOGetDevMap GetLegacyDevMap;
+ FBOGetDevMap GetUefiDevMap;
+ FBOGetDevMap GetDualDevMap;
+ FBOGetHiiMap GetHiiMap;
+ FBOGetBootOptionTokenMap GetBootOptionTokenMap; //(EIP123284+)
+ FBOGetNewDescription GetNewDescription ;
+} EFI_FIXED_BOOT_ORDER_PROTOCOL;
+
+
+#endif //#ifndef VFRCOMPILE
+
+//This structure is used for setup.
+typedef struct {
+ UINT8 LegacyDevice[FIXED_BOOT_ORDER_TOTAL_DEVICES_MAX_NUM]; //groups * submenu device.
+ UINT8 UefiDevice[FIXED_BOOT_ORDER_TOTAL_DEVICES_MAX_NUM]; //groups * submenu device.
+} FIXED_BOOT_SETUP;
+
+//This structure is used for FixedBootOrder Group control.
+typedef struct {
+ UINT8 LegacyHDD;
+ UINT8 LegacyODD;
+ UINT8 LegacyNET;
+ UINT8 LegacyUSBHDD;
+ UINT8 LegacyUSBODD;
+ UINT8 LegacyUSBFDD;
+ UINT8 LegacyUSBKEY;
+ UINT8 UefiHDD;
+ UINT8 UefiODD;
+ UINT8 UefiNET;
+ UINT8 UefiUSBHDD;
+ UINT8 UefiUSBODD;
+ UINT8 UefiUSBKEY;
+ UINT8 UefiUSBFDD; //(EIP96232+)
+} FIXED_BOOT_GROUP;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif //#ifndef _FIXED_BOOT_ORDER_H
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+
diff --git a/Board/EM/FixedBootOrder/FixedBootOrder.mak b/Board/EM/FixedBootOrder/FixedBootOrder.mak
new file mode 100644
index 0000000..23526c2
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrder.mak
@@ -0,0 +1,138 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2012, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+# $Header: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrder.mak 13 10/08/14 1:46a Dukeyeh $
+#
+# $Revision: 13 $
+#
+# $Date: 10/08/14 1:46a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrder.mak $
+#
+# 13 10/08/14 1:46a Dukeyeh
+# [TAG] EIP184538
+# [Category] Improvement
+# [Description] FixedBootOrder changes the values of variables in
+# StdDefaults variable and updates their checksum also if need be.
+# [Files] FixedBootOrder.c
+# FixedBootOrder.mak
+#
+# 12 1/26/13 2:57a Easonchen
+# [TAG] EIP112714
+# [Category] Improvement
+# [Description] Add include file elink
+# [Files]
+# FixedBootOrder.c
+# FixedBootOrder.sdl
+# FixedBootOrder.mak
+#
+# 11 6/28/12 11:23a Easonchen
+# Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+# functionality.
+#
+# 10 11/12/10 3:44a Easonchen
+# remove $(EFICOMMONLIB)
+#
+# 9 9/14/10 2:41a Easonchen
+# TAG: EIP41634
+# 1.Add file FBOHii.obj and $(EFICOMMONLIB) to SetupBin.
+#
+# 8 4/15/09 3:46a Jameswang
+# Added more include path for EDK.
+#
+# 7 3/26/09 2:45a Jameswang
+# Added include path to make all #include in source files not to use any
+# directory path.
+#
+# 6 3/02/09 3:21a Jameswang
+# Improvement: Do not need to modify the TSE core files.
+# Description: Separate OemFixedBootOrder to FBOSetOrder.c, this file
+# will be linked with TSE source to use hook BeforeLegacyBootLaunchHook
+#
+# 5 2/19/09 10:27p Jameswang
+# TAG: EIP19207
+# Bug fix: Fixed build error if x64_BUILD=1
+# Root cause: memset() is defined and linked in
+# AMIDXELIB:x64CLib.c:memset and
+# EFIDRIVERLIB:EFICOMMONLIB:COMPILERSTUB:memset.c
+# Solution: Avoid linking EFIDRIVERLIB
+#
+# Also, use inference rules to make override working.
+#
+# 4 3/21/08 5:09a Jameswang
+# (EIP12255) Do not need to link with minisetup for hooking on eLinks
+# because we do not use BOOT####. BOOT#### can not control individual
+# device boot order in each type.
+#
+# 3 2/20/08 12:56a Jameswang
+# Adds header.
+#
+#**********************************************************************
+
+# MAK file for the eModule:FixedBootOrder
+
+#<AMI_FHDR_START>
+#-----------------------------------------------------------------------
+# Name: FixedBootOrder.mak
+#
+# Description: This is a make file used to build component
+#
+#-----------------------------------------------------------------------
+#<AMI_FHDR_END>
+all : FixedBootOrder
+
+CORE_DXE_LIBBin : $(BUILD_DIR)\FBOSetOrder.obj
+
+FixedBootOrder : $(BUILD_DIR)\FixedBootOrder.mak $(BUILD_DIR)\FixedBootOrderStrTokens.h
+
+#-----------------------------------------------------------------------
+# Generic dependencies
+#-----------------------------------------------------------------------
+$(BUILD_DIR)\FixedBootOrder.mak : $(@B).cif $(FixedBootOrder_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(@B).cif $(CIF2MAK_DEFAULTS)
+
+#-----------------------------------------------------------------------
+# Paths and other definitions
+#-----------------------------------------------------------------------
+
+#-----------------------------------------------------------------------
+# AMICSP library files compilation
+#-----------------------------------------------------------------------
+{$(FixedBootOrder_DIR)}.c{$(BUILD_DIR)}.obj::
+ $(CC) $(CFLAGS) /I $(TSEBIN_DIR)\inc /I $(FixedBootOrder_DIR) /I $(Foundation_DIR) /I $(CORE_DXE_DIR) /I $(NVRAM_DIR) /Fo$(BUILD_DIR)\ $<
+
+AMITSEBin : $(BUILD_DIR)\FixedBootOrderTSE.obj
+SetupBin : $(BUILD_DIR)\FixedBootOrder.obj $(BUILD_DIR)\FixedBootOrderHII.obj $(BUILD_DIR)\NVRAMDXE.lib
+
+$(BUILD_DIR)\FixedBootOrder.obj : $(BUILD_DIR)\FixedBootOrderStrTokens.h
+
+$(BUILD_DIR)\FixedBootOrderStrTokens.h : $(FIXEDBOOTORDER_STRTOKENS_INCLUDE_FILES)
+ if exist $(BUILD_DIR)\FixedBootOrderStrTokens.h del $(BUILD_DIR)\FixedBootOrderStrTokens.h
+ $(SILENT) for %%f in ($(**:"=)) do $(ECHO) #include "%%f" >> $@
+
+#-----------------------------------------------------------------------
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2012, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/Board/EM/FixedBootOrder/FixedBootOrder.sdl b/Board/EM/FixedBootOrder/FixedBootOrder.sdl
new file mode 100644
index 0000000..1589fc7
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrder.sdl
@@ -0,0 +1,280 @@
+TOKEN
+ Name = "FIXED_BOOT_ORDER_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable module support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "BOOT_OPTION_GET_BBS_ENTRY_DEVICE_TYPE_FUNCTION"
+ Value = "FBO_GetBbsEntryDeviceType"
+ Help = "Name of the function of type GET_BBS_ENTRY_DEVICE_TYPE.\The function is used to convert device type stored in the BBS table to a legacy device type that will be stored in the NVRAM.\The default implementation(GetBbsEntryDeviceTypeDefault) provides support for BBS_USB_DEVICE_TYPE_SUPPORT and BBS_NETWORK_DEVICE_TYPE_SUPPORT SDL tokens."
+ TokenType = Expression
+ TargetH = Yes
+ Token = "CSM_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "INITIAL_LEGCAY_HII_ITEM_FUNCTION"
+ Value = "InitialLegacyHiiItemDefault"
+ Help = "Name of the function of FBO_INITIAL_HII_ITEM.\The function is initial legacy boot option hii database item."
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "INITIAL_UEFI_HII_ITEM_FUNCTION"
+ Value = "InitialUefiHiiItemDefault"
+ Help = "Name of the function of FBO_INITIAL_HII_ITEM.\The function is initial uefi boot option hii database item."
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "INITIAL_LEGCAY_GROUP_FUNCTION"
+ Value = "InitLegacyGroupDefault"
+ Help = "Name of the function of FBO_INITIAL_GROUP.\The function is initial legacy boot option device name."
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "INITIAL_UEFI_GROUP_FUNCTION"
+ Value = "InitUefiGroupDefault"
+ Help = "Name of the function of FBO_INITIAL_GROUP.\The function is initial uefi boot option device name."
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "USBKEY_RANGE_SIZE"
+ Value = "32000"
+ Help = "USB key memory size define.\Exsample:\32000 is 32G.\64000 is 64G."
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SETUP_RUNTIME_IFR_PROCESSING"
+ Value = "1"
+ Help = "Processes IFR data that are added to hii at runtime. This will cause an increased FW footprint and remove AMIBCP compatibility for those new pages."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FIXED_BOOT_SWAP_POLICY"
+ Value = "0"
+ Help = "0 = Swap option which is duplicated after boot priority is changed in TSE\1 = Swap nearby option (moving up and down)"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP"
+ Value = "1"
+ Help = "ON - Display device name in boot priority.\OFF - Just display type."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FIXED_BOOT_INCLUDE_DISABLED_OPTION"
+ Value = "1"
+ Help = "ON - Include Disabled to each boot priority control. NOTE: System will be reset after priorities got changed.\OFF - No Disabled option"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetH = Yes
+ Token = "FIXED_BOOT_SWAP_POLICY" "=" "0"
+End
+
+TOKEN
+ Name = "EDK_1_05_RETRIEVE_DATA"
+ Value = "0"
+ Help = "Modified code to return BrowserCallback String according to either EDK browser or spec. Please be careful when to change this to 0, May cause Addon Card to not to work."
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+ Token = "EFI_SPECIFICATION_VERSION" ">=" "0x2000A"
+End
+
+TOKEN
+ Name = "TSE_SAVE_DISABLED_BBS_DEVICEPATH"
+ Value = "0"
+ Help = "1 => Saves the DevicePaths of Disabled BBS devices to NVRAM Variable. \Depends on that varaible to keep device disbaled in next boot. \0 => Doesn't save the Disabled BBS devicepath."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_LOAD_OPTION_HIDDEN"
+ Value = "1"
+ Help = "1 => Hide LOAD_OPTION_HIDDEN Boot option. 0 => Shows all boot options."
+ TokenType = Boolean
+ TargetH = Yes
+ Token = "EFI_SPECIFICATION_VERSION" ">" "0x20000"
+End
+
+TOKEN
+ Name = "USE_BCP_DEFAULT_PRIORITIES"
+ Value = "0"
+ Help = "1 => Use file .sd BcpDefaultPriorities[] set default boot sequence."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FBO_USE_BOOT_OPTION_NUMBER_UNI"
+ Value = "0"
+ Help = "1 => Use Boot Option number unicode string with .UNI file."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FBO_DUAL_MODE"
+ Value = "0"
+ Help = "1 = Legacy/Uefi mix display."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FBO_WTG_PRIORITY_UPDATE"
+ Value = "1"
+ Help = "1 = Update Priorities when User set Windows To Go to 1st Priority in Windows To Go Startup."
+ TokenType = Boolean
+ TargetH = Yes
+ Token = "RestoreSpecialBootOptions_SUPPORT" "=" "1"
+End
+
+TOKEN
+ Name = "FIXED_BOOT_ORDER_SUBMENU_MAX_NUM"
+ Value = "16"
+ Help = "All SubMenu Total boot options."
+ TokenType = Integer
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FIXED_BOOT_ORDER_GROUP_MAX_NUM"
+ Value = "16"
+ Help = "Maximum number of groups."
+ TokenType = Integer
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FIXED_BOOT_ORDER_TOTAL_DEVICES_MAX_NUM"
+ Value = "$(FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)*$(FIXED_BOOT_ORDER_GROUP_MAX_NUM)"
+ Help = "Maximum number of devices."
+ TokenType = Integer
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+PATH
+ Name = "FixedBootOrder_DIR"
+End
+
+MODULE
+ Help = "Includes FixedBootOrder.mak to Project"
+ File = "FixedBootOrder.mak"
+End
+
+ELINK
+ Name = "FBO_Init,"
+ Parent = "ReadBootOptions,"
+ InvokeOrder = BeforeParent
+End
+
+ELINK
+ Name = "FixedBootOrderStringInit,"
+ Parent = "SetupStringInit"
+ Help = "Install form callback for each control"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "FixedBootOrderSaveChange,"
+ Parent = "SavedConfigChangesHook,"
+ Help = "Save Changed boot order"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "FixedBootOrderLoadedConfigDefaults,"
+ Parent = "LoadedConfigDefaultsHook,"
+ Help = "Loaded boot order Defaults"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "FBO_Protocol_install,"
+ Parent = "MinisetupDriverEntryHook,"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "FBO_UpdateBootListPriority,"
+ Parent = "SaveLegacyDevOrder,"
+ InvokeOrder = BeforeParent
+End
+
+ELINK
+ Name = "FboSyncBootOptionsFromDevOrder,"
+ Parent = "CreateBootOptionsForNewBootDevices,"
+ InvokeOrder = BeforeParent
+ Priority = 1
+End
+
+ELINK
+ Name = "FBO_AdjustPriority,"
+ Parent = "ReadBootOptions,"
+ InvokeOrder = AfterParent
+ Token = "FBO_WTG_PRIORITY_UPDATE" "=" "1"
+End
+
+ELINK
+ Name = "FBO_SetDefaultUEFIDevOrder,"
+ Parent = "SaveBootOptions,"
+ InvokeOrder = BeforeParent
+End
+
+ELINK
+ Name = "FixedBootOrderSetupEnter,"
+ Parent = "ProcessEnterSetupHook,"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "FixedBootOrderToBoot,"
+ Parent = "ProcessProceedToBootHook,"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\SetupStrTokens.h"
+ Parent = "FIXEDBOOTORDER_STRTOKENS_INCLUDE_FILES"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "FIXEDBOOTORDER_STRTOKENS_INCLUDE_FILES"
+ InvokeOrder = ReplaceParent
+End
+
+ELINK
+ Name = "AdjustLegacyBootOptionPriorities,"
+ Parent = "UpdateBootOptionVariables,"
+ Token = "CSM_SUPPORT" "=" "1"
+ Token = "GROUP_BOOT_OPTIONS_BY_TAG" "=" "1"
+ InvokeOrder = AfterParent
+ Disable = Yes
+End
diff --git a/Board/EM/FixedBootOrder/FixedBootOrderHII.c b/Board/EM/FixedBootOrder/FixedBootOrderHII.c
new file mode 100644
index 0000000..5cf8669
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrderHII.c
@@ -0,0 +1,888 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+//*****************************************************************//
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderHII.c $
+//
+// $Author: Easonchen $
+//
+// $Revision: 4 $
+//
+// $Date: 8/12/13 4:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderHII.c $
+//
+// 4 8/12/13 4:20a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] CppCheck error fix.
+// [Files] FixedBootOrderHII.c
+//
+// 3 11/09/12 2:40a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] Enhance function CreateHiiOneOfOptionItem()
+// [Files] FixedBootOrderHii.c
+//
+// 2 6/28/12 11:33a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS functionality
+//
+// 1 6/28/12 11:23a Easonchen
+//
+//*****************************************************************//
+
+
+//<AMI_FHDR_START>
+//**********************************************************************
+//
+// Name: FixedBootOrderHII.c
+//
+// Description: HiiDatabase Related Functions
+//
+//**********************************************************************
+//<AMI_FHDR_END>
+
+#include <efi.h>
+#include <AmiDxeLib.h>
+#include <token.h>
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+#include <Protocol/HiiConfigAccess.h>
+#include <Protocol/HiiString.h>
+#include <Protocol/HiiDatabase.h>
+#else
+#include <Protocol/FormCallback.h>
+#include <HIIDB.h>
+#include <Protocol/ExtHii.h>
+#endif
+
+#include <Setup.h>
+#include <SetupStrTokens.h>
+#include <AUTOID.h>
+
+#include "FixedBootOrderHII.h"
+
+UINTN FormPackageLength=10;
+VOID *hiiFormPackage=NULL;
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+#pragma pack(1)
+
+typedef struct _EFI_IFR_GUID_LABEL {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 Number;
+} EFI_IFR_GUID_LABEL;
+#pragma pack()
+//
+// GUIDed opcodes defined for Tiano
+//
+#define EFI_IFR_TIANO_GUID \
+ { 0xf0b1735, 0x87a0, 0x4193, 0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }
+
+EFI_GUID mIfrVendorGuid = EFI_IFR_TIANO_GUID;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiCompareGuid
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN EFI_GUID *Guid1, IN EFI_GUID *Guid2
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN
+EfiCompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+{
+ return (BOOLEAN)(0==MemCmp((UINT8*)Guid1,(UINT8*)Guid2,sizeof(EFI_GUID)));
+}
+
+EFI_STATUS
+GetPackageDataFromPackageList (
+ IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
+ IN UINT32 PackageIndex,
+ OUT UINT32 *BufferLen,
+ OUT EFI_HII_PACKAGE_HEADER **Buffer
+ )
+{
+ UINT32 Index;
+ EFI_HII_PACKAGE_HEADER *Package;
+ UINT32 Offset;
+ UINT32 PackageListLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader = {0, 0};
+
+ ASSERT(HiiPackageList != NULL);
+
+ if ((BufferLen == NULL) || (Buffer == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Package = NULL;
+ Index = 0;
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ pBS->CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+ while (Offset < PackageListLength) {
+ Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);
+ pBS->CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ if (Index == PackageIndex) {
+ break;
+ }
+ Offset += PackageHeader.Length;
+ Index++;
+ }
+ if (Offset >= PackageListLength) {
+ //
+ // no package found in this Package List
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ *BufferLen = PackageHeader.Length;
+ *Buffer = Package;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+UpdateFormPackageData (
+ IN EFI_GUID *FormSetGuid,
+ IN EFI_FORM_ID FormId,
+ IN EFI_HII_PACKAGE_HEADER *Package,
+ IN UINT32 PackageLength,
+ IN UINT16 Label,
+ IN BOOLEAN Insert,
+ IN EFI_HII_UPDATE_DATA *Data,
+ OUT UINT8 **TempBuffer,
+ OUT UINT32 *TempBufferSize
+ )
+{
+ UINT8 *BufferPos;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ UINT32 Offset;
+ EFI_IFR_OP_HEADER *IfrOpHdr;
+ BOOLEAN GetFormSet;
+ BOOLEAN GetForm;
+ UINT8 ExtendOpCode;
+ UINT16 LabelNumber;
+ BOOLEAN Updated;
+
+ if ((TempBuffer == NULL) || (TempBufferSize == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *TempBufferSize = PackageLength;
+ if (Data != NULL) {
+ *TempBufferSize += Data->Offset;
+ }
+ *TempBuffer = Malloc (*TempBufferSize);
+ if (*TempBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ pBS->CopyMem (*TempBuffer, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ *TempBufferSize = sizeof (EFI_HII_PACKAGE_HEADER);
+ BufferPos = *TempBuffer + sizeof (EFI_HII_PACKAGE_HEADER);
+
+ pBS->CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));
+ Offset = sizeof (EFI_HII_PACKAGE_HEADER);
+ GetFormSet = (FormSetGuid == NULL) ? TRUE : FALSE;
+ GetForm = FALSE;
+ Updated = FALSE;
+
+ while (!Updated && Offset < PackageHeader.Length) {
+ pBS->CopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
+ BufferPos += IfrOpHdr->Length;
+ *TempBufferSize += IfrOpHdr->Length;
+
+ switch (IfrOpHdr->OpCode) {
+ case EFI_IFR_FORM_SET_OP :
+ if (FormSetGuid != NULL) {
+ if (MemCmp (&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid, sizeof (EFI_GUID)) == 0) {
+ GetFormSet = TRUE;
+ } else {
+ GetFormSet = FALSE;
+ }
+ }
+ break;
+
+ case EFI_IFR_FORM_OP:
+ if (MemCmp (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
+ GetForm = TRUE;
+ } else {
+ GetForm = FALSE;
+ }
+ break;
+
+ case EFI_IFR_GUID_OP :
+ if (!GetFormSet || !GetForm) {
+ //
+ // Go to the next Op-Code
+ //
+ break;
+ }
+TRACE((-1,"EFI_IFR_GUID_OP 1\n"));
+// TraceOutData( (UINT8*) &((EFI_IFR_GUID *) IfrOpHdr)->Guid, sizeof(EFI_GUID) );
+ if (!EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid)) {
+ //
+ // GUID mismatch, skip this op-code
+ //
+ break;
+ }
+
+
+ ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
+ pBS->CopyMem (&LabelNumber, &((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Number, sizeof (UINT16));
+
+TRACE((-1,"EFI_IFR_GUID_OP 2 ExtendOpCode=%x LabelNumber=%x Label=%x\n",ExtendOpCode, LabelNumber, Label));
+
+ if ((ExtendOpCode != EFI_IFR_EXTEND_OP_LABEL) || (LabelNumber != Label)) {
+ //
+ // Go to the next Op-Code
+ //
+ break;
+ }
+
+ if (Insert) {
+ //
+ // Insert data after current Label, skip myself
+ //
+TRACE((-1,"EFI_IFR_GUID_OP 3\n"));
+ Offset += IfrOpHdr->Length;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ } else {
+ //
+ // Replace data between two paired Label, try to find the next Label.
+ //
+ while (TRUE) {
+ Offset += IfrOpHdr->Length;
+ //
+ // Search the next label and Fail if not label found.
+ //
+ if (Offset >= PackageHeader.Length) {
+ goto Fail;
+ }
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ if (IfrOpHdr->OpCode == EFI_IFR_GUID_OP) {
+ ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
+ if (EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid) && ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {
+ break;
+ }
+ }
+ }
+ }
+
+ //
+ // Fill in the update data
+ //
+ if (Data != NULL) {
+TRACE((-1,"EFI_IFR_GUID_OP 4\n"));
+ pBS->CopyMem (BufferPos, Data->Data, Data->Offset);
+ BufferPos += Data->Offset;
+ *TempBufferSize += Data->Offset;
+ }
+
+ //
+ // Copy the reset data
+ //
+ pBS->CopyMem (BufferPos, IfrOpHdr, PackageHeader.Length - Offset);
+ *TempBufferSize += PackageHeader.Length - Offset;
+
+ Updated = TRUE;
+ break;
+ default :
+ break;
+ }
+
+ //
+ // Go to the next Op-Code
+ //
+ Offset += IfrOpHdr->Length;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ }
+
+ //
+ // Update the package length.
+ //
+ PackageHeader.Length = *TempBufferSize;
+ pBS->CopyMem (*TempBuffer, &PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));
+
+Fail:
+ if (!Updated) {
+ pBS->FreePool (*TempBuffer);
+ *TempBufferSize = 0;
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+
+
+EFI_STATUS
+IfrLibUpdateForm (
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_GUID *FormSetGuid, OPTIONAL
+ IN EFI_FORM_ID FormId,
+ IN UINT16 Label,
+ IN BOOLEAN Insert,
+ IN EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ This function allows the caller to update a form that has
+ previously been registered with the EFI HII database.
+
+Arguments:
+ Handle - Hii Handle
+ FormSetGuid - The formset should be updated.
+ FormId - The form should be updated.
+ Label - Update information starting immediately after this label in the IFR
+ Insert - If TRUE and Data is not NULL, insert data after Label.
+ If FALSE, replace opcodes between two labels with Data
+ Data - The adding data; If NULL, remove opcodes between two Label.
+
+Returns:
+ EFI_SUCCESS - Update success.
+ Other - Update fail.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINT32 Index;
+ EFI_HII_PACKAGE_LIST_HEADER *UpdateBuffer;
+ UINTN BufferSize;
+ UINT8 *UpdateBufferPos;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ EFI_HII_PACKAGE_HEADER *Package;
+ UINT32 PackageLength;
+ EFI_HII_PACKAGE_HEADER *TempBuffer;
+ UINT32 TempBufferSize;
+ BOOLEAN Updated;
+
+ if (Data == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+// LocateHiiProtocols ();
+ Status = pBS->LocateProtocol(&gEfiHiiDatabaseProtocolGuid, NULL, &HiiDatabase);
+ //HiiDatabase = gIfrLibHiiDatabase;
+
+ //
+ // Get the orginal package list
+ //
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = Malloc (BufferSize);
+ ASSERT (HiiPackageList != NULL);
+
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (EFI_ERROR (Status)) {
+ pBS->FreePool (HiiPackageList);
+ return Status;
+ }
+ }
+
+ //
+ // Calculate and allocate space for retrieval of IFR data
+ //
+ BufferSize += Data->Offset;
+ UpdateBuffer = Malloc (BufferSize);
+ if (UpdateBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ UpdateBufferPos = (UINT8 *) UpdateBuffer;
+
+ //
+ // copy the package list header
+ //
+ pBS->CopyMem (UpdateBufferPos, HiiPackageList, sizeof (EFI_HII_PACKAGE_LIST_HEADER));
+ UpdateBufferPos += sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+
+ Updated = FALSE;
+ for (Index = 0; ; Index++) {
+ Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);
+ if (Status == EFI_SUCCESS) {
+ pBS->CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ if ((PackageHeader.Type == EFI_HII_PACKAGE_FORMS) && !Updated) {
+ Status = UpdateFormPackageData (FormSetGuid, FormId, Package, PackageLength, Label, Insert, Data, (UINT8 **)&TempBuffer, &TempBufferSize);
+ if (!EFI_ERROR(Status)) {
+ if (FormSetGuid == NULL) {
+ Updated = TRUE;
+ }
+ pBS->CopyMem (UpdateBufferPos, TempBuffer, TempBufferSize);
+ UpdateBufferPos += TempBufferSize;
+ pBS->FreePool (TempBuffer);
+ continue;
+ }
+ }
+
+ pBS->CopyMem (UpdateBufferPos, Package, PackageLength);
+ UpdateBufferPos += PackageLength;
+ } else if (Status == EFI_NOT_FOUND) {
+ break;
+ } else {
+ pBS->FreePool (HiiPackageList);
+ return Status;
+ }
+ }
+
+ //
+ // Update package list length
+ //
+ BufferSize = UpdateBufferPos - (UINT8 *) UpdateBuffer;
+ pBS->CopyMem (&UpdateBuffer->PackageLength, &BufferSize, sizeof (UINT32));
+
+ pBS->FreePool (HiiPackageList);
+
+ Status = HiiDatabase->UpdatePackageList (HiiDatabase, Handle, UpdateBuffer);
+
+ pBS->FreePool(UpdateBuffer);
+
+ return Status;
+}
+#endif //#if EFI_SPECIFICATION_VERSION>0x20000
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: CreateHiiOneOfItem
+//
+// Description: Create a Hii OneOf Item.
+//
+// Input:
+// UINT8 **IfrBufferPtr,
+// UINT16 VarStoreId,
+// UINT16 VarOffset,
+// UINT16 CallBackKey,
+// STRING_REF StrTokenId,
+// STRING_REF StrTokenHelpId,
+// UINT8 Flags
+//
+// Output:
+// EFI_STATUS
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CreateHiiOneOfItem(
+ UINT8 **IfrBufferPtr,
+ UINT16 VarStoreId,
+ UINT16 VarOffset,
+ UINT16 CallBackKey,
+ STRING_REF StrTokenId,
+ STRING_REF StrTokenHelpId,
+ UINT8 Flags)
+{
+ EFI_IFR_ONE_OF IfrOneOf;
+
+ IfrOneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
+ IfrOneOf.Header.Length = sizeof(EFI_IFR_ONE_OF);
+ IfrOneOf.Header.Scope = TRUE;
+ IfrOneOf.Question.Header.Prompt = StrTokenId;
+ IfrOneOf.Question.Header.Help = StrTokenHelpId;
+ IfrOneOf.Question.QuestionId = CallBackKey; //CallBack Key.
+ IfrOneOf.Question.VarStoreId = VarStoreId; //Variable ID
+ IfrOneOf.Question.VarStoreInfo.VarOffset = VarOffset;
+ IfrOneOf.Question.Flags = 04; //EFI_IFR_FLAG_INTERACTIVE
+ IfrOneOf.Flags = Flags;
+ IfrOneOf.data.u64.MinValue = 0;
+ IfrOneOf.data.u64.MaxValue = 0;
+ IfrOneOf.data.u64.Step = 0;
+
+ pBS->CopyMem( *IfrBufferPtr, &IfrOneOf, sizeof(EFI_IFR_ONE_OF) );
+ *IfrBufferPtr += sizeof(EFI_IFR_ONE_OF);
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: CreateHiiOneOfOptionItem
+//
+// Description: Create a Hii OneOf Option Item.
+//
+// Input:
+// UINT8 **IfrBufferPtr
+// UINT8 Type
+// UINT16 Index
+// STRING_REF StrTokenId
+//
+// Output:
+// EFI_STATUS
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CreateHiiOneOfOptionItem(UINT8 **IfrBufferPtr, UINT8 Type, UINT16 Index, STRING_REF StrTokenId)
+{
+ EFI_IFR_ONE_OF_OPTION IfrOneOfOptiopn;
+
+ IfrOneOfOptiopn.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
+ IfrOneOfOptiopn.Header.Length = sizeof(EFI_IFR_ONE_OF_OPTION);
+ IfrOneOfOptiopn.Header.Scope = FALSE;
+ IfrOneOfOptiopn.Option = StrTokenId;
+ IfrOneOfOptiopn.Flags = 0;
+ IfrOneOfOptiopn.Type = Type;
+
+ switch( Type )
+ {
+ case 0:
+ IfrOneOfOptiopn.Value.u8 = (UINT8)Index;
+ break;
+ case 1:
+ IfrOneOfOptiopn.Value.u16 = Index;
+ break;
+
+ }
+
+ pBS->CopyMem ( *IfrBufferPtr, &IfrOneOfOptiopn, sizeof(EFI_IFR_ONE_OF_OPTION) );
+ *IfrBufferPtr += sizeof(EFI_IFR_ONE_OF_OPTION);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: CreateHiiRefItem
+//
+// Description: Create a Hii Ref Item.
+//
+// Input:
+// UINT8 **IfrBufferPtr
+// UINT16 FromID
+// STRING_REF StrTokenId1
+// STRING_REF StrTokenId2
+//
+// Output:
+// EFI_STATUS
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CreateHiiRefItem(UINT8 **IfrBufferPtr, UINT16 FromID, STRING_REF StrTokenId1, STRING_REF StrTokenId2)
+{
+ EFI_IFR_REF IfrRef;
+
+ IfrRef.Header.OpCode = EFI_IFR_REF_OP;
+ IfrRef.Header.Length = sizeof(EFI_IFR_REF);
+ IfrRef.Header.Scope = FALSE;
+ IfrRef.Question.Header.Prompt = StrTokenId1;
+ IfrRef.Question.Header.Help = StrTokenId2;
+ IfrRef.Question.QuestionId = 0x10; //CallBack Key.
+ IfrRef.Question.VarStoreId = 0; //Setup Variable ID
+ IfrRef.Question.VarStoreInfo.VarOffset = 0xFFFF;
+ IfrRef.Question.Flags = 00; //INTERACTIVE;
+ IfrRef.FormId = FromID;
+
+ pBS->CopyMem ( *IfrBufferPtr, &IfrRef, sizeof(EFI_IFR_REF) );
+ *IfrBufferPtr += sizeof(EFI_IFR_REF);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: CreateHiiIfrEndItem
+//
+// Description: Create a Ifr End Item.
+//
+// Input:
+// UINT8 **IfrBufferPtr
+// Output:
+// EFI_STATUS
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CreateHiiIfrEndItem(UINT8 **IfrBufferPtr)
+{
+ EFI_IFR_END IfrEnd;
+
+ IfrEnd.Header.OpCode = EFI_IFR_END_OP;
+ IfrEnd.Header.Length = sizeof(EFI_IFR_END);
+ IfrEnd.Header.Scope = FALSE;
+
+ pBS->CopyMem( *IfrBufferPtr, &IfrEnd, sizeof(EFI_IFR_END) );
+ *IfrBufferPtr += sizeof(EFI_IFR_END);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: CreateHiiSubtitleItem
+//
+// Description: Create a Subtitle Item.
+//
+// Input:
+// UINT8 **IfrBufferPtr
+// STRING_REF StrTokenId
+// STRING_REF HelpStrTokenId
+// UINT8 Flags
+//
+// Output:
+// EFI_STATUS
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CreateHiiSubtitleItem(UINT8 **IfrBufferPtr, STRING_REF StrTokenId, STRING_REF HelpStrTokenId, UINT8 Flags )
+{
+ EFI_IFR_SUBTITLE IfrSubtitle;
+ IfrSubtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
+ IfrSubtitle.Header.Length = sizeof(EFI_IFR_SUBTITLE);
+ IfrSubtitle.Header.Scope = TRUE;
+ IfrSubtitle.Statement.Prompt = StrTokenId;
+ IfrSubtitle.Statement.Help = HelpStrTokenId;
+ IfrSubtitle.Flags = Flags;
+
+ pBS->CopyMem( *IfrBufferPtr, &IfrSubtitle, sizeof(EFI_IFR_SUBTITLE) );
+ *IfrBufferPtr += sizeof(EFI_IFR_SUBTITLE);
+ return EFI_SUCCESS;
+};
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: CreateHiiIfrFormItem
+//
+// Description: Create a Form Item.
+//
+// Input:
+// UINT8 **IfrBufferPtr
+// UINT16 FromID
+// STRING_REF StrTokenId
+//
+// Output:
+// EFI_STATUS
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CreateHiiIfrFormItem(UINT8 **IfrBufferPtr, UINT16 FromID, STRING_REF StrTokenId)
+{
+ EFI_IFR_FORM IfrForm;
+
+ IfrForm.Header.OpCode = EFI_IFR_FORM_OP;
+ IfrForm.Header.Length = sizeof(EFI_IFR_FORM);
+ IfrForm.Header.Scope = TRUE;
+ IfrForm.FormId = FromID;
+ IfrForm.FormTitle = StrTokenId;
+
+ pBS->CopyMem( *IfrBufferPtr, &IfrForm, sizeof(EFI_IFR_FORM) );
+ *IfrBufferPtr += sizeof(EFI_IFR_FORM);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: InitHiiData
+//
+// Description: Use HiiDatabaseProtocol get hii data package to buffer
+//
+// Input:
+// EFI_HANDLE HiiHandle
+//
+// Output:
+// NONE
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void InitHiiData(EFI_HANDLE HiiHandle)
+{
+
+EFI_GUID gEfiHiiDatabaseProtocolGuid = EFI_HII_DATABASE_PROTOCOL_GUID;
+EFI_HII_DATABASE_PROTOCOL *gHiiDatabase;
+EFI_STATUS status;
+
+
+ status = pBS->LocateProtocol(&gEfiHiiDatabaseProtocolGuid, NULL, &gHiiDatabase);
+ if(EFI_ERROR(status)) return;
+ hiiFormPackage = Malloc(FormPackageLength);
+ status = gHiiDatabase->ExportPackageLists(gHiiDatabase, HiiHandle, &FormPackageLength, hiiFormPackage);
+ TRACE((-1,"[FBOHii.c] ExportPackageLists...%r\n", status));
+
+ if( status == EFI_BUFFER_TOO_SMALL)
+ {
+
+ pBS->FreePool(hiiFormPackage);
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ hiiFormPackage = Malloc(FormPackageLength);
+
+ if (hiiFormPackage == NULL)
+ {
+ hiiFormPackage = NULL;
+ return;
+ }
+ //
+ // Get all the packages associated with this HiiHandle
+ //
+ status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &FormPackageLength, hiiFormPackage);
+ TRACE((-1,"[FBOHii.c] Again ExportPackageLists...%r size=%x\n", status, FormPackageLength));
+// TraceOutData( (UINT8 *)hiiFormPackage, FormPackageLength);
+ }
+
+}
+
+void FreeHiiData()
+{
+ if(hiiFormPackage)
+ pBS->FreePool(hiiFormPackage);
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FIndVariableID
+//
+// Description: Search Hii Form Package Data of variable ID.
+//
+// Input:
+// CHAR8 *VarName
+// Output:
+// UINT16 VarID
+// Modified:
+// NONE
+// Referrals:
+// NONE
+// Notes:
+// NONE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 FIndVariableID(CHAR8 *VarName )
+{
+ EFI_HII_PACKAGE_HEADER *pkgHdr;
+
+
+ UINT32 offset = 0;
+
+ EFI_IFR_OP_HEADER *IfrData;
+ UINT32 SeekSize=0;
+ UINT32 FormSize=0;
+
+ if( hiiFormPackage == NULL ) return 0;
+
+ offset = sizeof(EFI_HII_PACKAGE_LIST_HEADER);
+
+ while( offset < ((EFI_HII_PACKAGE_LIST_HEADER*)hiiFormPackage)->PackageLength )
+ {
+ UINT8 *pkgOffset;
+ pkgOffset = ((UINT8*)hiiFormPackage) + offset;
+ pkgHdr = (EFI_HII_PACKAGE_HEADER*)pkgOffset;
+
+ TRACE((-1,"[FixedBootOrderHII.c] pkgHdr=%x Type=%x Length=%x\n", (UINT8*)pkgHdr-(UINT8*)hiiFormPackage,
+ pkgHdr->Type,
+ pkgHdr->Length ));
+
+ switch(pkgHdr->Type)
+ {
+ case EFI_HII_PACKAGE_FORMS:
+ IfrData = (EFI_IFR_OP_HEADER*) ((UINT8 *)pkgHdr+sizeof(EFI_HII_PACKAGE_HEADER));
+ FormSize=pkgHdr->Length;
+ while(1)
+ {
+ if(IfrData->OpCode == EFI_IFR_VARSTORE_OP)
+ {
+
+// TRACE((-1,"[FixedBootOrderHii.c] VarID=%x Name=%s\n", ((EFI_IFR_VARSTORE*)IfrData)->VarStoreId,
+// ((EFI_IFR_VARSTORE*)IfrData)->Name ));
+
+
+ if( !Strcmp(VarName, ((EFI_IFR_VARSTORE*)IfrData)->Name) )
+ return ((EFI_IFR_VARSTORE*)IfrData)->VarStoreId;
+ }
+ SeekSize+=IfrData->Length;
+ (UINT8 *)IfrData+=IfrData->Length;
+
+ if(!IfrData->Length) break;
+ if(SeekSize >= FormSize) break;
+ }
+ return 0;
+ break;
+
+ case EFI_HII_PACKAGE_END:
+ return 0;
+ break;
+
+ default:
+ break;
+ }
+ offset += pkgHdr->Length;
+ }
+ return 0;
+}
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Board/EM/FixedBootOrder/FixedBootOrderHII.h b/Board/EM/FixedBootOrder/FixedBootOrderHII.h
new file mode 100644
index 0000000..edbe955
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrderHII.h
@@ -0,0 +1,128 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+//*****************************************************************//
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderHII.h $
+//
+// $Author: Easonchen $
+//
+// $Revision: 2 $
+//
+// $Date: 6/28/12 11:34a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderHII.h $
+//
+// 2 6/28/12 11:34a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS functionality
+//
+// 1 6/28/12 11:23a Easonchen
+//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//**********************************************************************
+//
+// Name: FixedBootOrderHii.h
+//
+// Description: Header file of FixedBootOrder module
+//
+//**********************************************************************
+//<AMI_FHDR_END>
+
+
+#ifndef _FIXED_BOOT_ORDER_HII_H
+#define _FIXED_BOOT_ORDER_HII_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma pack(1)
+#if EFI_SPECIFICATION_VERSION>0x20000
+
+typedef struct {
+ //
+ // Buffer size allocated for Data.
+ //
+ UINT32 BufferSize;
+
+ //
+ // Offset in Data to append the newly created opcode binary.
+ // It will be adjusted automatically in Create***OpCode(), and should be
+ // initialized to 0 before invocation of a serial of Create***OpCode()
+ //
+ UINT32 Offset;
+
+ //
+ // The destination buffer for created op-codes
+ //
+ UINT8 *Data;
+} EFI_HII_UPDATE_DATA;
+#endif
+
+#define EFI_IFR_EXTEND_OP_LABEL 0x0
+#define EFI_IFR_EXTEND_OP_BANNER 0x1
+#define EFI_IFR_EXTEND_OP_TIMEOUT 0x2
+#define EFI_IFR_EXTEND_OP_CLASS 0x3
+#define EFI_IFR_EXTEND_OP_SUBCLASS 0x4
+
+#pragma pack()
+
+EFI_STATUS
+IfrLibUpdateForm (
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_GUID *FormSetGuid, OPTIONAL
+ IN EFI_FORM_ID FormId,
+ IN UINT16 Label,
+ IN BOOLEAN Insert,
+ IN EFI_HII_UPDATE_DATA *Data
+ );
+
+
+EFI_STATUS CreateHiiOneOfItem(UINT8 **IfrBufferPtr, UINT16 VarStoreId, UINT16 VarOffset, UINT16 CallBackKey, STRING_REF StrTokenId, STRING_REF StrTokenHelpId, UINT8 Flags);
+EFI_STATUS CreateHiiOneOfOptionItem(UINT8 **IfrBufferPtr, UINT8 Type, UINT16 Index, STRING_REF StrTokenId);
+EFI_STATUS CreateHiiRefItem(UINT8 **IfrBufferPtr, UINT16 FromID, STRING_REF StrTokenId1, STRING_REF StrTokenId2);
+EFI_STATUS CreateHiiIfrFormItem(UINT8 **IfrBufferPtr, UINT16 FromID, STRING_REF StrTokenId);
+EFI_STATUS CreateHiiIfrEndItem(UINT8 **IfrBufferPtr);
+EFI_STATUS CreateHiiSubtitleItem(UINT8 **IfrBufferPtr, STRING_REF StrTokenId, STRING_REF HelpStrTokenId, UINT8 Flags );
+
+UINT16 FIndVariableID(CHAR8 *VarName );
+
+void InitHiiData(EFI_HANDLE HiiHandle);
+void FreeHiiData();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif //#ifndef _FIXED_BOOT_ORDER_HII_H
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+
diff --git a/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.c b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.c
new file mode 100644
index 0000000..22d01ee
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.c
@@ -0,0 +1,482 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderStyle.c $
+//
+// $Author: Easonchen $
+//
+// $Revision: 3 $
+//
+// $Date: 8/12/13 4:33a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderStyle.c $
+//
+// 3 8/12/13 4:33a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] CppCheck error fix.
+// [Files] FixedBootOrderStyle.c
+//
+// 2 2/21/13 1:19a Easonchen
+// [TAG] N/A
+// [Description] Add Null pointer check
+// [Files] FixedBootOrderStyle.c
+//
+// 1 6/28/12 11:42a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+// functionality.
+//
+//
+//*****************************************************************//
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: FixedBootOrderStyle.c
+//
+// Description: Replace TSE funtion Popupsel.Draw PopupSel.HandleAction
+// Frame.HandleAction
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "minisetup.h"
+#include "build\autoid.h"
+#include <FixedBootOrder.h>
+#include <Setup.h>
+
+#define VARIABLE_ID_SETUP 0
+
+UINT16 LegacyBootItemCount=1;
+UINT16 UefiBootItemCount=1;
+UINT16 DualBootItemCount=1;
+
+extern NVRAM_VARIABLE *gVariableList;
+
+VOID _PopupSelGetSelection( POPUPSEL_DATA *popupSel );
+EFI_STATUS _FrameHandleKey( FRAME_DATA *frame, AMI_EFI_KEY_DATA Key );
+EFI_STATUS _FrameScroll( FRAME_DATA *frame, BOOLEAN bScrollUp );
+
+EFI_STATUS CheckFixedBootOrder( CONTROL_DATA *control, FRAME_DATA *frame, AMI_EFI_KEY_DATA key ) // (EIP19998+)
+{
+ POPUPSEL_DATA *popupsel=NULL;
+ CONTROL_ACTION Action;
+ UINT16 StartKey, EndKey;
+
+ popupsel = (POPUPSEL_DATA*)control;
+
+ //Get mapping
+ Action = MapControlKeysHook(key);
+
+ if( Action == ControlActionDecreament
+ || Action == ControlActionIncreament )
+ {
+ if( popupsel->CallBackKey >= LegacyBootItemKey
+ && popupsel->CallBackKey < LegacyBootItemKey+LegacyBootItemCount )
+ {
+ StartKey=LegacyBootItemKey;
+ EndKey=(LegacyBootItemKey+LegacyBootItemCount)-1;
+ }
+ else
+ if( popupsel->CallBackKey >= UefiBootItemKey
+ && popupsel->CallBackKey < UefiBootItemKey+UefiBootItemCount )
+ {
+ StartKey=UefiBootItemKey;
+ EndKey=(UefiBootItemKey+UefiBootItemCount)-1;
+ }
+#if FBO_DUAL_MODE
+ else
+ if( popupsel->CallBackKey >= DualBootItemKey
+ && popupsel->CallBackKey < DualBootItemKey+DualBootItemCount )
+ {
+ StartKey=DualBootItemKey;
+ EndKey=(DualBootItemKey+DualBootItemCount)-1;
+ TRACE((-1,"CheckFixedBootOrder DUAL..\n"));
+ }
+#endif
+ }
+
+
+ switch (Action)
+ {
+ case ControlActionDecreament:
+ if (popupsel->CallBackKey == StartKey)
+ break;
+ _FrameScroll( frame, TRUE);
+ break;
+
+ case ControlActionIncreament:
+ if (popupsel->CallBackKey == EndKey)
+ break;
+ _FrameScroll( frame, FALSE);
+ break;
+
+ default:
+ return EFI_ABORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS OemBootOrderPopupSelDraw( POPUPSEL_DATA *popupSel )
+{
+ CHAR16 *text=NULL,*text1=NULL;
+ UINTN i,Len=0;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 Index = 0;
+ UINT16 *OptionList=NULL;
+ UINT64 *ValueList=NULL;
+ SETUP_DATA *pSetup;
+ UINT8 ColorNSel = popupSel->NSelFGColor;
+ UINT8 ColorLabel = (popupSel->ControlFocus) ? popupSel->LabelFGColor : popupSel->NSelLabelFGColor ;
+
+ pSetup = (SETUP_DATA*)gVariableList[VARIABLE_ID_SETUP].Buffer;
+
+ if( !pSetup->BootMode ) //LEGACY BOOT ITEM
+ {
+ if (!((popupSel->CallBackKey >= LegacyBootItemKey) &&
+ (popupSel->CallBackKey < LegacyBootItemKey+LegacyBootItemCount )))
+ {
+ return PopupSelDraw(popupSel);
+ }
+ }
+ else
+ if( pSetup->BootMode == 1 ) //UEFI BOOT ITEM
+ {
+ if (!((popupSel->CallBackKey >= UefiBootItemKey) &&
+ (popupSel->CallBackKey < UefiBootItemKey+UefiBootItemCount )))
+ {
+ return PopupSelDraw(popupSel);
+ }
+ }
+#if FBO_DUAL_MODE
+ else
+ if( pSetup->BootMode == 2 ) //DUAL BOOT ITEM
+ {
+ if (!((popupSel->CallBackKey >= DualBootItemKey) &&
+ (popupSel->CallBackKey < DualBootItemKey+DualBootItemCount )))
+ {
+ return PopupSelDraw(popupSel);
+ }
+ }
+#endif
+
+ if( popupSel->ListBoxCtrl != NULL)
+ {
+ gListBox.Draw( popupSel->ListBoxCtrl );
+ }
+ else
+ {
+ // check conditional ptr if necessary
+ if( popupSel->ControlData.ControlConditionalPtr != 0x0)
+ {
+ switch( CheckControlCondition( &popupSel->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorNSel = ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ }
+ // If not Special
+ if(TseLiteIsSpecialOptionList((CONTROL_DATA *)popupSel) != TRUE)
+ {
+ Status = UefiGetOneOfOptions(&popupSel->ControlData,&popupSel->PopupSelHandle,
+ &OptionList, &ValueList, &popupSel->ItemCount,NULL,NULL);
+ if (EFI_ERROR(Status))
+ return Status;
+ for( Index = 0; Index < popupSel->ItemCount; Index++ )
+ {
+ popupSel->PtrTokens[Index].Option = OptionList[Index];
+ popupSel->PtrTokens[Index].Value = ValueList[Index];
+ }
+ MemFreePointer( (VOID **)&(OptionList));
+ MemFreePointer( (VOID **)&(ValueList));
+ }
+
+ _PopupSelGetSelection( popupSel );
+ text1 = HiiGetString( popupSel->ControlData.ControlHandle, popupSel->Title );
+ if ( text1 != NULL )
+ {
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ // Adjust fixed boot order position
+// if (((popupSel->CallBackKey&0x0F) >= 1) && ((popupSel->CallBackKey&0x0F) <= FBO_Device_Count))
+// {
+
+ if (popupSel->LabelMargin != SET_BOOT_OPTION_TEXT_POSITION)
+ {
+ popupSel->LabelMargin = SET_BOOT_OPTION_TEXT_POSITION;
+ popupSel->Left = popupSel->Left + SET_BOOT_OPTION_NUMBER_POSITION;
+// if (popupSel->Left + TestPrintLength(text1) > popupSel->LabelMargin)
+// popupSel->LabelMargin = (UINT16)(popupSel->Left + TestPrintLength(text1));
+ popupSel->Width = popupSel->Width - SET_BOOT_OPTION_NUMBER_POSITION;
+ }
+// Len = TestPrintLength( text1 ) / (NG_SIZE);
+// }
+#endif
+
+#if TSE_MULTILINE_CONTROLS
+ if(popupSel->Height>1)
+ {
+ DrawMultiLineStringWithAttribute( (UINTN)popupSel->Left, (UINTN) popupSel->Top,
+ (UINTN)(popupSel->LabelMargin - popupSel->Left),(UINTN) popupSel->Height,
+ text1, popupSel->BGColor | ColorLabel );
+ }
+ else
+#endif
+ {
+ // boundary overflow check
+ if((TestPrintLength( text1) / (NG_SIZE))> (UINTN)(popupSel->LabelMargin - popupSel->Left ))
+ text1[HiiFindStrPrintBoundary(text1 ,(UINTN)(popupSel->LabelMargin - popupSel->Left ))] = L'\0';
+
+ DrawStringWithAttribute( popupSel->Left , popupSel->Top, (CHAR16*)text1,
+ popupSel->BGColor | ColorLabel );
+
+ }
+ MemFreePointer( (VOID **)&text1 );
+ }
+
+ /*EfiStrCpy(text, L"[");
+ DrawStringWithAttribute( popupSel->Left + popupSel->LabelMargin , popupSel->Top, (CHAR16*)text,
+ (UINT8)( (popupSel->ControlFocus) ?
+ popupSel->SelBGColor | popupSel->SelFGColor :
+ popupSel->BGColor | ColorNSel ));
+*/
+
+ text1 = HiiGetString( popupSel->PopupSelHandle, popupSel->PtrTokens[popupSel->Sel].Option);
+
+ if(!text1)
+ text1 = EfiLibAllocateZeroPool(2);
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ popupSel->LabelMargin = SET_BOOT_OPTION_TEXT_POSITION;
+#endif
+ //MemSet( text, sizeof(text), 0 );
+ Len = TestPrintLength( text1 ) / (NG_SIZE);
+ // XXX: may be broken for wide character languages !!!
+ if ( Len /*StringDisplayLen( text1 )*/ > /*19*/(UINTN)(popupSel->Width - popupSel->LabelMargin -2)/*gControlRightAreaWidth*/ )
+ EfiStrCpy(&text1[HiiFindStrPrintBoundary(text1 ,(UINTN)(popupSel->Width - popupSel->LabelMargin /*gControlRightAreaWidth*/-5/*16*/))],L"..." );
+
+
+ text = EfiLibAllocateZeroPool( (Len+3)*2 );
+#if FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP
+ SPrint( text,(UINTN)( (Len+3)*2 )/*(popupSel->Width - popupSel->Left - popupSel->LabelMargin +2)*/, L"%s", text1 );
+#else
+ SPrint( text,(UINTN)( (Len+3)*2 )/*(popupSel->Width - popupSel->Left - popupSel->LabelMargin +2)*/, L"[%s]", text1 );
+#endif
+ MemFreePointer( (VOID **)&text1 );
+ DrawStringWithAttribute( popupSel->Left + popupSel->LabelMargin , popupSel->Top, (CHAR16*)text,
+ (UINT8)( (popupSel->ControlFocus) ?
+ popupSel->SelBGColor | popupSel->SelFGColor :
+ popupSel->BGColor | ColorNSel ));
+
+
+ i=TestPrintLength(text) / (NG_SIZE);
+ MemFreePointer( (VOID **)&text );
+ /*EfiStrCpy(text, L"]");
+ DrawStringWithAttribute( popupSel->Left + popupSel->LabelMargin +i +1, popupSel->Top, (CHAR16*)text,
+ (UINT8)( (popupSel->ControlFocus) ?
+ popupSel->SelBGColor | popupSel->SelFGColor :
+ popupSel->BGColor | ColorNSel ));
+*/
+ // erase extra spaces if neccessary
+ for(;(UINT16)(popupSel->Left + popupSel->LabelMargin + i) <= (popupSel->Width-1);i++)
+ DrawStringWithAttribute( popupSel->Left + popupSel->LabelMargin +i, popupSel->Top, L" ",
+ popupSel->BGColor | ColorNSel );
+
+ FlushLines( popupSel->Top, popupSel->Top+popupSel->Height );
+ }
+
+ return Status;
+}
+
+EFI_STATUS OemBootOrderFrameHandleAction( FRAME_DATA *frame, ACTION_DATA *action )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_DATA **control;
+
+
+ if ( frame->ControlCount == 0 )
+ return Status;
+
+ if(frame->CurrentControl == FRAME_NONE_FOCUSED)
+ control = NULL;
+ else
+ control = &frame->ControlList[frame->CurrentControl];
+
+ if( control != NULL )
+ {
+ SETUP_DATA *pSetup;
+ POPUPSEL_DATA *popupsel=NULL;
+ popupsel = (POPUPSEL_DATA*)(*control);
+
+ pSetup = (SETUP_DATA*)gVariableList[VARIABLE_ID_SETUP].Buffer;
+
+ if( pSetup->BootMode == 0 )
+ {
+ if (!((popupsel->CallBackKey >= LegacyBootItemKey) &&
+ (popupsel->CallBackKey < LegacyBootItemKey+LegacyBootItemCount)))
+ {
+ return FrameHandleAction(frame, action);
+ }
+ }
+ else
+ if( pSetup->BootMode == 1 )
+ {
+ if (!((popupsel->CallBackKey >= UefiBootItemKey) &&
+ (popupsel->CallBackKey < UefiBootItemKey+UefiBootItemCount)))
+ {
+ return FrameHandleAction(frame, action);
+ }
+ }
+#if FBO_DUAL_MODE
+ else
+ if( pSetup->BootMode == 2 )
+ {
+ if (!((popupsel->CallBackKey >= DualBootItemKey) &&
+ (popupsel->CallBackKey < DualBootItemKey+DualBootItemCount)))
+ {
+ return FrameHandleAction(frame, action);
+ }
+ }
+#endif
+ }
+
+ switch ( action->Input.Type )
+ {
+
+ case ACTION_TYPE_MOUSE:
+ Status = MouseFrameHandleAction(frame,action,control);
+ break;
+
+ case ACTION_TYPE_KEY:
+ if ( control != NULL )
+ {
+ Status = (*control)->Methods->HandleAction( *control, action );
+ CheckFixedBootOrder( *control, frame, action->Input.Data.AmiKey ); //(EIP10461+)(EIP19998)+)
+ }
+
+ if (EFI_ERROR(Status))
+ Status = StyleFrameHandleKey( frame, action->Input.Data.AmiKey.Key );
+
+ if (EFI_ERROR(Status))
+ Status = _FrameHandleKey( frame, action->Input.Data.AmiKey );
+ break;
+
+ case ACTION_TYPE_TIMER:
+ {
+ UINT32 i;
+ control = frame->ControlList;
+ for ( i = 0; i < frame->ControlCount; i++, control++ )
+ {
+ EFI_STATUS TempStatus = (*control)->Methods->HandleAction( *control, action );
+ if ( Status != EFI_SUCCESS )
+ Status = TempStatus;
+ }
+ // To kill the timer action. Pass it to all the controls and frame.
+ // gAction.ClearAction( action );
+ }
+
+ if (EFI_ERROR(Status))
+ Status = StyleFrameHandleTimer( frame, action);
+ break;
+ default:
+ break;
+ }
+
+ return Status;
+}
+
+EFI_STATUS OemPopupSelHandleAction( POPUPSEL_DATA *popupSel, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ AMI_EFI_KEY_DATA key=Data->Input.Data.AmiKey;
+
+ // Disable enter key in FixedBootOrder item
+ if ((popupSel->CallBackKey >= LegacyBootItemKey) &&
+ (popupSel->CallBackKey < LegacyBootItemKey+LegacyBootItemCount))
+ {
+ if (Data->Input.Type == ACTION_TYPE_KEY)
+ if (MapControlKeysHook(key) == ControlActionSelect)
+ return Status;
+ }
+ else
+ if ((popupSel->CallBackKey >= UefiBootItemKey) &&
+ (popupSel->CallBackKey < UefiBootItemKey+UefiBootItemCount))
+ {
+ if (Data->Input.Type == ACTION_TYPE_KEY)
+ if (MapControlKeysHook(key) == ControlActionSelect)
+ return Status;
+ }
+#if FBO_DUAL_MODE
+ else
+ if ((popupSel->CallBackKey >= DualBootItemKey) &&
+ (popupSel->CallBackKey < DualBootItemKey+DualBootItemCount))
+ {
+ if (Data->Input.Type == ACTION_TYPE_KEY)
+ if (MapControlKeysHook(key) == ControlActionSelect)
+ return Status;
+ }
+#endif
+
+ Status = PopupSelHandleAction(popupSel, Data);
+
+ return Status;
+}
+
+UINT16 GetDevMapDataCount(FBODevMap *pFBODevMap); //at file FixedBootOrderTSE.c
+
+VOID FixedBootOrderStyleProcessEnterSetup(VOID)
+{
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ EFI_STATUS Status;
+ EFI_FIXED_BOOT_ORDER_PROTOCOL *pFBO=NULL;
+
+ gFrame.HandleAction = OemBootOrderFrameHandleAction;
+ gPopupSel.Draw = OemBootOrderPopupSelDraw;
+ gPopupSel.HandleAction = OemPopupSelHandleAction;
+
+ Status = pBS->LocateProtocol( &FixedBootOrderGuid, NULL, &pFBO );
+ if(EFI_ERROR(Status)) return;
+
+ LegacyBootItemCount = GetDevMapDataCount(pFBO->GetLegacyDevMap());
+ UefiBootItemCount = GetDevMapDataCount(pFBO->GetUefiDevMap());
+#if FBO_DUAL_MODE
+ DualBootItemCount = GetDevMapDataCount(pFBO->GetDualDevMap());
+#endif
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.cif b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.cif
new file mode 100644
index 0000000..b773d23
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.cif
@@ -0,0 +1,10 @@
+<component>
+ name = "Style - Up/Down move mode"
+ category = ModulePart
+ LocalRoot = "Board\EM\FixedBootOrder\FixedBootOrderStyle\"
+ RefName = "FixedBootOrderStyle"
+[files]
+"FixedBootOrderStyle.c"
+"FixedBootOrderStyle.mak"
+"FixedBootOrderStyle.sdl"
+<endComponent>
diff --git a/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.mak b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.mak
new file mode 100644
index 0000000..3da37a6
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.mak
@@ -0,0 +1,95 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2012, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+#**********************************************************************
+# $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderStyle.mak $
+#
+# $Author: Easonchen $
+#
+# $Revision: 1 $
+#
+# $Date: 6/28/12 11:42a $
+#
+#*****************************************************************
+#*****************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderStyle.mak $
+#
+# 1 6/28/12 11:42a Easonchen
+# Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS
+# functionality.
+#
+#
+#*****************************************************************
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: FixedBootOrderStyle.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+OEM_BOOTORDDER_STYLE_INCLUDES = \
+ -I $(TSE_STYLE_DIR) \
+!if "$(UEFI_SOURCES_SUPPORT)" == "1"
+ -I $(UEFISRC_DIR) \
+!endif
+ -I $(TSELITESRC_DIR) \
+ -I $(TSESRC_DIR)\AMILogo \
+ -I $(TSESRC_DIR) \
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(PROJECT_DIR)\$(FixedBootOrder_DIR)\
+ -I $(BUILD_DIR) \
+
+$(BUILD_DIR)\FixedBootOrderStyle.lib : FixedBootOrderStyleLib
+
+FixedBootOrderStyleLib : $(BUILD_DIR)\FixedBootOrderStyle.mak FixedBootOrderStyleLibBin
+
+$(BUILD_DIR)\FixedBootOrderStyle.mak : $(FixedBootOrderStyle_DIR)\$(@B).cif $(FixedBootOrderStyle_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(FixedBootOrderStyle_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+FixedBootOrderStyleLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\FixedBootOrderStyle.mak all\
+ "MY_INCLUDES=$(OEM_BOOTORDDER_STYLE_INCLUDES)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\FixedBootOrderStyle.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2012, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.sdl b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.sdl
new file mode 100644
index 0000000..b5072ed
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.sdl
@@ -0,0 +1,51 @@
+TOKEN
+ Name = "FixedBootOrderStyle_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable S4ResumeTemplate support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Token = "FIXED_BOOT_SWAP_POLICY" "=" "1"
+End
+
+TOKEN
+ Name = "SET_BOOT_OPTION_TEXT_POSITION"
+ Value = "6"
+ Help = "Set boot option text position."
+ TokenType = Integer
+ TargetH = Yes
+ Token = "FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP" "=" "1"
+End
+
+TOKEN
+ Name = "SET_BOOT_OPTION_NUMBER_POSITION"
+ Value = "2"
+ Help = "Set boot option number position."
+ TokenType = Integer
+ TargetH = Yes
+ Token = "FIXED_BOOT_DISPLAY_DEVICE_NAME_IN_SETUP" "=" "1"
+End
+
+PATH
+ Name = "FixedBootOrderStyle_DIR"
+End
+
+MODULE
+ Help = "Includes FixedBootOrderStyle_DIR.mak to Project"
+ File = "FixedBootOrderStyle.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\FixedBootOrderStyle.lib"
+ Parent = "MINISETUPLIB"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "FixedBootOrderStyleProcessEnterSetup,"
+ Parent = "ProcessEnterSetup,"
+ InvokeOrder = AfterParent
+End
+
diff --git a/Board/EM/FixedBootOrder/FixedBootOrderTSE.c b/Board/EM/FixedBootOrder/FixedBootOrderTSE.c
new file mode 100644
index 0000000..c7e93fc
--- /dev/null
+++ b/Board/EM/FixedBootOrder/FixedBootOrderTSE.c
@@ -0,0 +1,1478 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+// $Archive: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderTSE.c $Author:
+//
+// $Revision: 19 $Date:
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/Template/FixedBootOrder Demo/Board/em/FixedBootOrder/FixedBootOrderTSE.c $
+//
+// 19 4/02/15 5:00a Klzhan
+// [TAG] EIPNone
+// [Category] Improvement
+// [Description] Define TSE_MAX_DRIVE_NAME if not defined.
+//
+// 18 3/26/15 10:50p Walonli
+// [TAG] EIP210628
+// [Category] Improvement
+// [Description] Fixed build error when USE_BCP_DEFAULT_PRIORITIES token
+// enable.
+// [Files] Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// FixedBootOrder.cif
+//
+// 17 1/27/15 1:22a Walonli
+// [TAG] EIP198610
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Boot wrong device when group disable/enable
+// [RootCause] FixedBootOrder doesn't check group disable when Save and
+// Exit.
+// [Solution] Add code to check group status(enable/disable)
+//
+// 16 9/09/14 3:36a Dukeyeh
+// [TAG] EIP171752
+// [Category] Improvement
+// [Description] Add FIXED_BOOT_ORDER_SUBMENU_MAX_NUM and
+// FIXED_BOOT_ORDER_GROUP_MAX_NUM tokens to decide maximum number of
+// submenus and groups at boot time.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+//
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 15 8/13/14 11:19p Walonli
+// [TAG] EIP180632
+// [Category] New Feature
+// [Description] Add FixedBootOrder Protocol to change device/group
+// name.
+// [Files] Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// FixedBootOrder.cif
+//
+// 14 8/12/14 5:53a Dukeyeh
+//
+// 13 8/06/14 8:27a Dukeyeh
+// [TAG] EIP179738
+// [Category] Bug Fix
+// [RootCause]
+// 1. Set FboLegacyDevOrder variable error because of wrong attribute.
+// 2. In FixedBootOrderSaveChange function,
+// if LoadedDefault is true, it would use the DefaultLegacyDevOrder
+// variable to adjust order,
+// but the device type is wrong becasue it has already changed into BBS
+// spec. specified one.
+//
+// [Solution]
+// 1. Set the FboLegacyDevOrder variable with right attribute.
+// 2. FixedBootOrderSaveChange doesn't need to
+// get DefaultLegacyDevOrder to set order, using FboLegacyDevOrder
+// instead.
+//
+//
+// [Files] FixedBootOrderTSE.c
+//
+// 12 7/24/14 4:21a Klzhan
+// [TAG] EIP177104
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] System show no boot device when change mode and disable all
+// bootoptions
+// [RootCause] FBO will skip the boot option that attrib is hidden.
+// [Solution] When change mode, also clear hidden attribute.
+//
+// 11 5/20/14 3:48a Klzhan
+// [TAG] EIP167196
+// [Category] Improvement
+// [Description] Runtime attribute set for the some of the variable used
+// by FixedBootOrder needs to be reviewed.
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 10 4/15/14 2:26a Klzhan
+// [TAG] EIP143078
+// [Category] Improvement
+// [Description] Set LOAD_OPTION_ACTIVE must be 0 when
+// LOAD_OPTION_HIDDEN=1
+// [Files] Board\em\FixedBootOrder\FixedBootOrder.sdl
+// Board\em\FixedBootOrder\FixedBootOrder.mak
+// Board\em\FixedBootOrder\FBOSetOrder.c
+// Board\em\FixedBootOrder\FixedBootOrderTSE.c
+// Board\em\FixedBootOrder\FixedBootOrder.h
+// Board\em\FixedBootOrder\FixedBootOrder.c
+// Board\em\FixedBootOrder\FixedBootOrder.chm
+// Board\em\FixedBootOrder\FixedBootOrderHII.c
+// Board\em\FixedBootOrder\FixedBootOrderHII.h
+// FixedBootOrder.cif
+//
+// 9 10/25/13 5:53a Easonchen
+// [TAG] EIPEIP129692.2
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] BBS Priorities become DISABLE when set ENABLE in Boot
+// Option Priorities
+// [RootCause] Variable "UefiDevOrder" not set "Disable" Mask.
+// [Solution] Add "Disable" mask to variable "UefiDevOrder".
+// [Files]
+// FboSetOrder.c
+// FixedBootOrderTse.c
+//
+// 8 10/21/13 5:54a Easonchen
+// [TAG] EIP129692
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BBS Priorities become DISABLE when set ENABLE in Boot
+// Option Priorities
+// [RootCause] Variable "UefiDevOrder" not set "Disable" Mask.
+// [Solution] Add "Disable" mask to variable "UefiDevOrder"
+// [Files]
+// FboSetOrder.c
+// FixedBootOrderTse.c
+//
+// 7 8/12/13 4:21a Easonchen
+// [TAG] N/A
+// [Category] Improvement
+// [Description] CppCheck error fix.
+// [Files] FixedBootOrderTSE.c
+//
+// 6 5/31/13 2:31a Easonchen
+// [TAG] EIP123284
+// [Category] Improvement
+// [Description] Set Boot Priority unicode string
+// [Files] FixedBootOrder.c
+// FixedBootOrder.h
+// FixedBootOrder.sdl
+// FixedBootOrderTSE.c
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 5 5/28/13 5:27a Easonchen
+// [TAG] EIP122146
+// [Category] Improvement
+// [Description] Support Dual mode default priority with tool AMIBCP.
+// [Files]
+// FboSetOrder.c
+// FixedBootOrder.c
+// FixedBoorOrderTse.c
+// DefaultFixedBootOrder.c
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 4 4/22/13 11:17p Easonchen
+// [TAG] EIP121259
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] when selected save & exit from setup exit page, the system
+// can't boot into Dos.
+// [RootCause] BootOrder variable not update.
+// [Solution] Add BootOrder variable update at ProcessProceedToBootHook.
+// [Files] FixedBootOrderTSE.c
+//
+// 3 2/05/13 3:49a Easonchen
+// [TAG] EIP107268
+// [Category] New Feature
+// [Description] Add support managing default boot order list using
+// AMIBCP.
+// [Files]
+// FBOSetOrder.c
+// FixedBootOrder.c
+// FixedBootOrderTSE.c
+// FixedBootOrder.sdl
+// DefaultFixedBootOrder.sd
+// DefaultFixedBootOrder.uni
+//
+// 2 6/28/12 11:34a Easonchen
+// Make a new FixedBootOrder module by utilizing 4.6.4.1 BDS functionality
+//
+// 1 6/28/12 11:22a Easonchen
+//*****************************************************************//
+
+
+//<AMI_FHDR_START>
+//---------------------------------------------------------------------------
+//
+// Name: FixedBootOrderTSE.c
+//
+// Description: TSE Related Functions
+//
+//---------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+//---------------------------------------------------------------------------
+// Include Files
+//---------------------------------------------------------------------------
+#include <efi.h>
+#include <token.h>
+#include <AmiDxeLib.h>
+#include <Variable.h>
+#if CSM_SUPPORT
+#include <Protocol\Legacybios.h>
+#endif
+#include <Protocol\HiiString.h>
+#include <Protocol\HiiDatabase.h>
+#include <Setup.h>
+#include <setupdata.h>
+#include "FixedBootOrderHII.h"
+#include "FixedBootOrder.h"
+#include "AMITSEStrTokens.h"
+//#include "SetupStrTokens.h"
+#include <AUTOID.h>
+#include <Uefihii.h>
+
+#include <boot.h>
+#define VARIABLE_ATTRIBUTES \
+ (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
+
+#pragma pack(1)
+typedef struct
+{
+ UINT32 Type;
+ UINT16 Length;
+ UINT16 Data[1];
+}
+LEGACY_DEVICE_ORDER;
+
+#if CSM_SUPPORT
+#ifndef TSE_MAX_DRIVE_NAME
+#define TSE_MAX_DRIVE_NAME 32
+#endif
+// To fix c compiler typedef is tagged but not implement.
+typedef struct _BBS_ORDER_LIST
+{
+ UINT16 Index;
+ CHAR16 Name[TSE_MAX_DRIVE_NAME];
+}
+BBS_ORDER_LIST;
+#endif
+#pragma pack()
+
+//---------------------------------------------------------------------------
+// External functions
+//---------------------------------------------------------------------------
+BOOLEAN BBSValidDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath );
+EFI_STATUS SetBootVariable( UINT16 BootIndex, BOOLEAN EnableDisable );
+CHAR16* Wcscpy(CHAR16 *string1, CHAR16* string2);
+UINTN Wcslen(CHAR16 *string);
+extern UINTN gBootOptionCount;
+extern NVRAM_VARIABLE *gVariableList;
+extern BOOT_DATA *gBootData;
+
+//---------------------------------------------------------------------------
+// Global Variable declarations
+//---------------------------------------------------------------------------
+#define DEFAULTS_GUID {0x4599d26f, 0x1a11, 0x49b8, 0xb9, 0x1f, 0x85, 0x87, 0x45, 0xcf, 0xf8, 0x24}
+
+EFI_GUID DefaultLegacyDevOrderGuid = DEFAULT_LEGACY_DEV_ORDER_VARIABLE_GUID;
+EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+BOOLEAN LoadedDefault = FALSE;
+FBODevMap *pFBOLegacyDevMap = NULL;
+FBODevMap *pFBOUefiDevMap = NULL;
+FBODevMap *pFBODualDevMap = NULL;
+FBOHiiMap *pFBOHiiMap = NULL;
+UINT16 *pBootOptionTokenMap = NULL; //(EIP123284+)
+FBO_DEVICE_INFORM *pFBONewDevDescription = NULL ;
+EFI_HII_STRING_PROTOCOL *gHiiString = NULL;
+CHAR8 Language[] = "en-US";
+EFI_HII_HANDLE HiiHandle;
+extern NVRAM_VARIABLE *gVariableList;
+
+UINT16 GetDevMapDataCount(FBODevMap *pFBODevMap)
+{
+ UINT16 count = 0;
+
+ if( !pFBODevMap ) return 0;
+
+ do{
+ if( pFBODevMap[count].DevType == 0 ) break;
+ count++;
+ }while(1);
+
+ return count;
+}
+
+
+UINT16 GetHiiMapMapCount()
+{
+ UINT16 count = 0;
+
+ if( !pFBOHiiMap ) return 0;
+
+ do{
+ if( pFBOHiiMap[count].DevType == 0 ) break;
+ count++;
+ }while(1);
+
+ return count;
+}
+
+UINT16 SearchDevMapByType(FBODevMap *pFBODevMap, UINT16 DevType )
+{
+ UINT16 i=0;
+
+ do{
+ if(pFBODevMap[i].DevType == 0 ) break;
+ if(pFBODevMap[i].DevType == DevType)
+ return i;
+ i++;
+ }while(1);
+
+ return 0;
+}
+
+UINT16 SearchHiiMapByType(UINT16 DevType)
+{
+ UINT16 i=0;
+
+ do{
+ if(pFBOHiiMap[i].DevType == 0 ) break;
+ if(pFBOHiiMap[i].DevType == DevType)
+ return i;
+ i++;
+ }while(1);
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FixedBootOrderSetupEnter
+//
+// Description: TSE Setup enter Hook.
+//
+// Input:
+// None
+//
+// Output:
+// None
+//
+// Modified:
+//
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN FBO_EnterSetup = FALSE;
+EFI_STATUS FixedBootOrderSetupEnter(IN void)
+{
+ TRACE((-1,"FixedBootOrder ELINK Setup Enter......\n"));
+ FBO_EnterSetup = TRUE;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FixedBootOrderToBoot
+//
+// Description:
+//
+// Input:
+// None
+//
+// Output:
+// None
+//
+// Modified:
+// variable "LegacyDevOrder", "UefiDevOrder".
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+extern BOOLEAN gEnterSetup;
+EFI_STATUS FixedBootOrderToBoot(IN void)
+{
+ EFI_STATUS Status;
+ EFI_GUID gSetupGuid=SETUP_GUID;
+ EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE;
+ SETUP_DATA *pSetupData=NULL;
+ UINT32 SetupAttr;
+ UINTN SetupSize=0;
+ UINT16 i, j, BootIndex=0;
+ UINT16 NewBootOrder[50];
+
+ TRACE((-1,"FixedBootOrderToBoot............\n"));
+ TRACE((-1,"FBO_EnterSetup=%d\n", FBO_EnterSetup));
+ //-------------------------------------------------------------------
+ if( !FBO_EnterSetup ) return EFI_SUCCESS;
+
+ Status = GetEfiVariable(L"Setup", &gSetupGuid, &SetupAttr, &SetupSize, &pSetupData);
+
+ if(pSetupData == NULL || EFI_ERROR(Status)) return Status;
+#if FBO_DUAL_MODE
+ if( pSetupData->BootMode == 2 ) //dual MODE?
+ {
+ VOID *DevOrderBuffer = NULL;
+ UINTN Size=0;
+ UINT16 DevCount=0;
+ DevCount = GetDevMapDataCount( pFBODualDevMap );
+
+ Status = GetEfiVariable( L"UefiDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer );
+ if( !EFI_ERROR( Status ) )
+ {
+ for( i=0; i<DevCount; i++)
+ {
+ UINT16 DevIndex;
+ UEFI_DEVICE_ORDER *DevOrder;
+
+ DevIndex=pSetupData->DualPriorities[i];
+ TRACE((-1,"pFBODualDevMap[%d].DevType=%x\n", DevIndex, pFBODualDevMap[DevIndex].DevType));
+
+ if( pFBODualDevMap[DevIndex].DevType == 0 ) continue; //Is Disable?
+
+ if( pFBODualDevMap[DevIndex].BBSType == 0 ) //Uefi boot option?
+ {
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ; DevOrder = (UEFI_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)) )
+ {
+ if( pFBODualDevMap[DevIndex].DevType == DevOrder->Type )
+ {
+ for(j=0; j<(DevOrder->Length-2)/sizeof(UINT16); j++)
+ {
+ TRACE((-1,"Uefi BootOrder Number = %04x\n", DevOrder->Device[j] & 0xff));
+ NewBootOrder[BootIndex]=DevOrder->Device[j] & 0xff;
+ BootIndex++;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ for( j=0; j<gBootOptionCount; j++)
+ {
+ BBS_BBS_DEVICE_PATH *BbsDp;
+
+ if( !BBSValidDevicePath(gBootData[j].DevicePath) ) continue;
+
+ BbsDp = (BBS_BBS_DEVICE_PATH*)gBootData[j].DevicePath;
+ if( pFBODualDevMap[DevIndex].DevType == BbsDp->DeviceType )
+ {
+ TRACE((-1,"Legacy BootOrder Number = %04x DeviceType = %02x \n", gBootData[j].Option, BbsDp->DeviceType));
+ NewBootOrder[BootIndex]=gBootData[j].Option;
+ BootIndex++;
+ }
+ }
+ }
+ }
+
+ if( DevOrderBuffer )
+ pBS->FreePool( DevOrderBuffer );
+ }
+ }
+ else
+#endif
+ if( pSetupData->BootMode == 1 ) //uefi MODE?
+ {
+ VOID *DevOrderBuffer = NULL;
+ UINTN Size=0;
+ UINT16 DevCount=0;
+ DevCount = GetDevMapDataCount( pFBOUefiDevMap );
+
+ Status = GetEfiVariable( L"UefiDevOrder", &FixedBootOrderGuid, NULL, &Size, &DevOrderBuffer );
+ if( !EFI_ERROR( Status ) )
+ {
+ for( i=0; i<DevCount; i++)
+ {
+ UINT16 DevIndex;
+ UEFI_DEVICE_ORDER *DevOrder;
+
+ TRACE((-1,"pSetupData->UefiPriorities[%d]=%d\n", i, pSetupData->UefiPriorities[i]));
+ DevIndex=pSetupData->UefiPriorities[i];
+ if( pFBOUefiDevMap[DevIndex].DevType == 0 ) continue; //Is Disable?
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ; DevOrder = (UEFI_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)) )
+ {
+ if( pFBOUefiDevMap[DevIndex].DevType == DevOrder->Type )
+ {
+ for(j=0; j<(DevOrder->Length-2)/sizeof(UINT16); j++)
+ {
+ NewBootOrder[BootIndex]=DevOrder->Device[j] & 0xff;
+ BootIndex++;
+ }
+ break;
+ }
+ }
+ }
+
+ if( DevOrderBuffer )
+ pBS->FreePool( DevOrderBuffer );
+ }
+ }
+ else //if( pSetupData->BootMode == 1 ) //uefi MODE?
+ if( pSetupData->BootMode == 0 ) //legacy MODE?
+ {
+ UINT16 LegacyDevCount=0;
+ LegacyDevCount = GetDevMapDataCount( pFBOLegacyDevMap );
+ for( i=0; i<LegacyDevCount; i++)
+ {
+ UINT16 DevIndex;
+ DevIndex=pSetupData->LegacyPriorities[i];
+ if( pFBOLegacyDevMap[DevIndex].DevType == 0 ) continue; //Is Disable?
+
+ for( j=0; j<gBootOptionCount; j++)
+ {
+ BBS_BBS_DEVICE_PATH *BbsDp;
+
+ if( !BBSValidDevicePath(gBootData[j].DevicePath) ) continue;
+
+ BbsDp = (BBS_BBS_DEVICE_PATH*)gBootData[j].DevicePath;
+ if( pFBOLegacyDevMap[DevIndex].DevType == BbsDp->DeviceType )
+ {
+ NewBootOrder[BootIndex]=gBootData[j].Option;
+ BootIndex++;
+ }
+ }
+ }
+ }
+
+ // Above loop for getting NewBootOrder will be skip if the group is disabled:
+ // pFBOXXXDevMap[DevIndex].DevType==0 (disable = last DevIndex in pFBOXXXDevMap which is 0)
+
+ // Here we have boot options which are not added because the group is disabled
+
+ for (i = 0; i < gBootOptionCount; i++)
+ {
+ // boot options with group enabled
+ for (j = 0; j < BootIndex; j++)
+ {
+ if (NewBootOrder[j] == gBootData[i].Option)
+ {
+ if (BBSValidDevicePath(gBootData[i].DevicePath))
+ {
+ // Legacy Boot Option
+ // Enable Legacy group option, attr |= ACTIVE
+ SetBootVariable(gBootData[i].Option, TRUE);
+ }
+ else
+ {
+ // UEFI Boot Option
+ // Due to EFI option is not group, so we need double check with device group sub menu.
+ VOID *UefiDevOrderBuffer = NULL;
+ UINTN UefiDevSize = 0 ;
+ UEFI_DEVICE_ORDER *DevOrder;
+ Status = GetEfiVariable( L"UefiDevOrder", &FixedBootOrderGuid, NULL, &UefiDevSize, &UefiDevOrderBuffer );
+ if (EFI_ERROR(Status)) continue ;
+ for (DevOrder = UefiDevOrderBuffer
+ ; (UINT8*)DevOrder < (UINT8*)UefiDevOrderBuffer + UefiDevSize
+ ; DevOrder = (UEFI_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)))
+ {
+ UINTN index ;
+ for (index = 0 ; index < DEVORDER_COUNT(DevOrder) ; index++)
+ {
+ if ((UINT16)DevOrder->Device[index] == gBootData[i].Option)
+ {
+ // Check device is enable or not in sub menu
+ if (DevOrder->Device[index] & FBO_UEFI_DISABLED_MASK)
+ SetBootVariable(gBootData[i].Option, FALSE);
+ else
+ SetBootVariable(gBootData[i].Option, TRUE);
+ break ;
+ }
+ }
+ }
+ if( UefiDevOrderBuffer )
+ pBS->FreePool( UefiDevOrderBuffer );
+ }
+ break;
+ }
+ }
+
+ // boot options with group disabled
+ // need to disable the boot#### variable directly
+ if (j == BootIndex)
+ {
+ NewBootOrder[BootIndex] = gBootData[i].Option;
+ BootIndex++;
+ SetBootVariable(gBootData[i].Option, FALSE);
+ }
+ }
+
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ {
+ // Put disable boot variable to last.
+ UINT16 *TempBootOrder = MallocZ(BootIndex * sizeof(UINT16));
+ UINT16 TempIndex = 0 ;
+
+
+ for (i = 0; i < gBootOptionCount; i++)
+ {
+ BOOT_DATA *pBootData = BootGetBootData(NewBootOrder[i]) ;
+ if (pBootData->Active & LOAD_OPTION_ACTIVE)
+ {
+ TempBootOrder[TempIndex] = NewBootOrder[i] ;
+ NewBootOrder[i] = 0xffff ; //added flag
+ TempIndex++ ;
+ }
+ }
+ for (i = 0; i < gBootOptionCount; i++)
+ {
+ if (NewBootOrder[i] != 0xffff)
+ {
+ TempBootOrder[TempIndex] = NewBootOrder[i] ;
+ TempIndex++ ;
+ }
+ }
+
+ MemCpy(NewBootOrder, TempBootOrder, BootIndex * sizeof(UINT16)) ;
+ pBS->FreePool(TempBootOrder);
+ }
+#endif
+
+ pRS->SetVariable(L"BootOrder",
+ &gEfiGlobalVariableGuid,
+ VARIABLE_ATTRIBUTES,
+ BootIndex * sizeof(UINT16),
+ NewBootOrder);
+
+ if( pSetupData )
+ pBS->FreePool( pSetupData );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SetBootVariable
+//
+// Description: Set Boot#### variable Enable/Disable.
+//
+// Input:
+// UINT16 BootIndex
+// BOOLEAN EnableDisable
+//
+// Output:
+// None
+//
+// Modified: variable Boot####.
+//
+// Referrals:
+//
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetBootVariable( UINT16 BootIndex, BOOLEAN EnableDisable )
+{
+ EFI_GUID EfiVariableGuid = EFI_GLOBAL_VARIABLE;
+ EFI_STATUS Status;
+ UINTN OptionSize=0;
+ UINT32 Attr = 0;
+ CHAR16 BootVarName[15];
+ UINT8 Buffer[0x200];
+ EFI_LOAD_OPTION *BootOption = NULL; //buffer for BootXXX variables
+
+ Swprintf( BootVarName, gBootName, BootIndex);
+
+ BootOption=(EFI_LOAD_OPTION*)Buffer;
+
+ OptionSize=sizeof(Buffer);
+ Status = pRS->GetVariable( BootVarName, &EfiVariableGuid, &Attr, &OptionSize, BootOption);
+
+
+ if( !EFI_ERROR(Status) )
+ {
+ BOOT_DATA *pBootData = BootGetBootData(BootIndex);
+ if(EnableDisable)
+ {
+ BootOption->Attributes |= LOAD_OPTION_ACTIVE;
+ BootOption->Attributes &= ~LOAD_OPTION_HIDDEN;
+ if (pBootData) pBootData->Active |= LOAD_OPTION_ACTIVE;
+ }
+ else
+ {
+ BootOption->Attributes&=~(LOAD_OPTION_ACTIVE);
+ if (pBootData) pBootData->Active &= ~(LOAD_OPTION_ACTIVE);
+ }
+
+ pRS->SetVariable( BootVarName,
+ &EfiVariableGuid,
+ Attr,
+ OptionSize,
+ BootOption);
+
+ TRACE((-1,"[FixedBootOrderTSE.c]::SetBootVariable(%d) Boot%04x=(%r)\n", EnableDisable, BootIndex, Status));
+ }
+
+ return Status;
+
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FixedBootOrderSaveChange
+//
+// Description: Save boot device priority to variable.
+//
+// Input:
+// None
+//
+// Output:
+// None
+//
+// Modified:
+// variable "LegacyDevOrder", "UefiDevOrder".
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FixedBootOrderSaveChange(IN void)
+{
+ EFI_STATUS Status;
+ UINTN Size, i=0;
+ UINTN VariableSize;
+ VOID *DevOrderBuffer=NULL;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ EFI_GUID LegacyDevOrderGuid = LEGACY_DEV_ORDER_GUID;
+ EFI_GUID gSetupGuid = SETUP_GUID;
+ FIXED_BOOT_SETUP FixedBootSetupData;
+ LEGACY_DEVICE_ORDER *NewDevBuffer, *NewDevBuffer2;
+ UINT32 Attr, LegacyDevAttr;
+ EFI_GUID gFixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+
+ VariableSize = sizeof(FIXED_BOOT_SETUP);
+
+ Status = pRS->GetVariable( L"FixedBoot",
+ &gSetupGuid,
+ NULL,
+ &VariableSize,
+ &FixedBootSetupData );
+
+ if(EFI_ERROR(Status))
+ {
+ TRACE((-1, "[FixedBoot SaveChange]GetVariable(FixedBoot):%r\n", Status));
+ return Status;
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // Update Variable "FboLegacyDevOrder"
+ //-------------------------------------------------------------------------------------------------------
+ Size = 0;
+ // Get LegacyDevOrder Attrib
+ Status = GetEfiVariable(L"LegacyDevOrder", &LegacyDevOrderGuid, &LegacyDevAttr, &Size, &DevOrderBuffer);
+
+ // Set Size to 0 for GetEfiVariable, DevOrderBuffer will also be clear in GetEfiVariable
+ Size = 0;
+ if(LoadedDefault)
+ {
+ Status = GetEfiVariable(L"DefaultLegacyDevOrder", &DefaultLegacyDevOrderGuid, &Attr, &Size, &DevOrderBuffer);
+ TRACE((-1, "[FixedBootOrderTSE.c] GetVariable(DefaultLegacyDevOrder):%r\n", Status));
+ }
+ else
+ {
+ Status = GetEfiVariable(L"FboLegacyDevOrder", &gFixedBootOrderGuid, &Attr, &Size, &DevOrderBuffer);
+ TRACE((-1, "[FixedBootOrderTSE.c] GetVariable(OldLegacyDevOrder):%r\n", Status));
+ }
+
+
+ NewDevBuffer2 = NewDevBuffer = Malloc( Size );
+
+ if (!EFI_ERROR(Status) && Size >= 6)
+ {
+ LEGACY_DEVICE_ORDER *DevOrder;
+ UINT16 *OrderData;
+ UINT8 *NVramOrderIndex;
+ UINT16 Index;
+ UINT16 DevDataIndex;
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ; DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)) )
+ {
+ UINT16 *NewOrderData;
+
+ pBS->CopyMem( NewDevBuffer,
+ DevOrder,
+ DevOrder->Length + sizeof(DevOrder->Type) );
+
+ NewOrderData=(UINT16*)&NewDevBuffer->Data[0];
+ OrderData = (UINT16*)&DevOrder->Data[0];
+ DevDataIndex = SearchDevMapByType( pFBOLegacyDevMap, DevOrder->Type );
+ NVramOrderIndex = &FixedBootSetupData.LegacyDevice[DevDataIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM];
+
+ TRACE((-1,"[FixedBootOrderTSE.c]DeviceType:%x (", DevOrder->Type));
+ for(i=0; i<(DevOrder->Length-2)/sizeof(UINT16); i++)
+ {
+ TRACE((-1,"%x ", OrderData[i]));
+ }
+ TRACE((-1,")\n"));
+
+ TRACE((-1,"[FixedBootOrderTSE.c]FixedBootSetupData DeviceType:%x (:", DevOrder->Type));
+ for(i=0; i<(DevOrder->Length-2)/sizeof(UINT16); i++)
+ {
+ if( i >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+
+ Index=NVramOrderIndex[i];
+ if(Index >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ break; //is Disable
+
+ TRACE((-1,"%x ",Index));
+ NewOrderData[i]= OrderData[Index] & 0xff;
+ OrderData[Index]=0xffff;
+ }
+
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ //Check Disable Item and SetMask
+ if(i<(DevOrder->Length-2)/sizeof(UINT16))
+ {
+ UINTN j;
+ TRACE((-1,"Disable: "));
+ for(j=0;j<(DevOrder->Length-2)/sizeof(UINT16);j++)
+ {
+ if(OrderData[j] == 0xffff) continue;
+
+ TRACE((-1,"%x ", OrderData[j]));
+ NewOrderData[i]= OrderData[j] | 0xff00;
+ i++;
+ }
+ }
+#endif
+ TRACE((-1,"\n"));
+
+ NewDevBuffer = (LEGACY_DEVICE_ORDER*)((UINT8*)NewDevBuffer
+ + NewDevBuffer->Length
+ + sizeof(NewDevBuffer->Type));
+ }
+
+ Status = pRS->SetVariable(L"FboLegacyDevOrder", &gFixedBootOrderGuid, Attr, Size, NewDevBuffer2);
+ // Priorities changed !! Sync with LegacyDevOrder
+ {
+ LEGACY_DEVICE_ORDER* TempDevOrder;
+ EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
+ UINT16 HddCount = 0;
+ HDD_INFO *LocalHddInfo = NULL;
+ UINT16 BbsCount = 0;
+ BBS_TABLE *BbsTable;
+ EFI_GUID gEfiLegacyBiosProtocolGuid = EFI_LEGACY_BIOS_PROTOCOL_GUID;
+ UINTN Offset = 0;
+
+ Status = pBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, &LegacyBios);
+ if (!EFI_ERROR (Status)) {
+ Status = LegacyBios->GetBbsInfo (
+ LegacyBios,
+ &HddCount,
+ &LocalHddInfo,
+ &BbsCount,
+ &BbsTable
+ );
+ }
+
+ for (TempDevOrder = NewDevBuffer2
+ ; (UINT8*)TempDevOrder < (UINT8*)NewDevBuffer2 + Size
+ ; TempDevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)TempDevOrder + TempDevOrder->Length + sizeof(TempDevOrder->Type)))
+ {
+
+ // Due to TSE SaveBBSOrder function will reassign gBootData->LegacyEntryOffset
+ // We need calculate offset again.
+ for (i = 0; i < gBootOptionCount; i++)
+ {
+ UINTN j;
+ BBS_ORDER_LIST *OrderList = gBootData[i].OrderList ;
+
+ for (j =0; j < gBootData[i].LegacyDevCount ; j++)
+ if ((OrderList[j].Index & FBO_LEGACY_ORDER_MASK) == TempDevOrder->Data[0])
+ break ;
+
+ if (j != gBootData[i].LegacyDevCount)
+ {
+ // Matched, update gBootData offset.
+ gBootData[i].LegacyEntryOffset = Offset ;
+ break ;
+ }
+ }
+ Offset += TempDevOrder->Length + sizeof(TempDevOrder->Type) ;
+ }
+ }
+ // Need to sync with LegacyDevOrder for TSE to boot (in case it continues to boot without reset)
+ Status = pRS->SetVariable(L"LegacyDevOrder", &LegacyDevOrderGuid, Attr, Size, NewDevBuffer2);
+ pBS->FreePool(DevOrderBuffer);
+
+ }
+
+ if( NewDevBuffer2 )
+ pBS->FreePool(NewDevBuffer2);
+ //-------------------------------------------------------------------------------------------------------
+ // Update Variable "UefiDevOrder"
+ //-------------------------------------------------------------------------------------------------------
+ Size = 0;
+ DevOrderBuffer=NULL;
+ if(LoadedDefault)
+ {
+ Status = GetEfiVariable(L"DefaultUefiDevOrder", &FixedBootOrderGuid, &Attr, &Size, &DevOrderBuffer);
+ TRACE((-1, "[FixedBootOrderTSE.c] GetVariable(DefaultUefiDevOrder):%r\n", Status));
+ }
+ else
+ {
+ Status = GetEfiVariable(L"OldUefiDevOrder", &FixedBootOrderGuid, &Attr, &Size, &DevOrderBuffer);
+ TRACE((-1, "[FixedBootOrderTSE.c] GetVariable(UefiDevOrder):%r\n", Status));
+ }
+
+ NewDevBuffer2 = NewDevBuffer = Malloc( Size );
+
+ if (!EFI_ERROR(Status) && Size >= 6)
+ {
+ LEGACY_DEVICE_ORDER *DevOrder;
+ UINT16 *OrderData;
+ UINT8 *NVramOrderIndex;
+ UINT16 Index;
+ UINT16 DevDataIndex;
+
+ for( DevOrder = DevOrderBuffer
+ ;(UINT8*)DevOrder<(UINT8*)DevOrderBuffer+Size
+ ; DevOrder = (LEGACY_DEVICE_ORDER*)((UINT8*)DevOrder + DevOrder->Length + sizeof(DevOrder->Type)) )
+ {
+ UINT16 *NewOrderData;
+
+ pBS->CopyMem( NewDevBuffer,
+ DevOrder,
+ DevOrder->Length + sizeof(DevOrder->Type) );
+
+ NewOrderData=(UINT16*)&NewDevBuffer->Data[0];
+ OrderData = (UINT16*)&DevOrder->Data[0];
+ DevDataIndex = SearchDevMapByType( pFBOUefiDevMap, DevOrder->Type );
+ NVramOrderIndex = &FixedBootSetupData.UefiDevice[DevDataIndex * FIXED_BOOT_ORDER_SUBMENU_MAX_NUM];
+
+ TRACE((-1,"[FixedBootOrderTSE.c]DeviceType:%x (", DevOrder->Type));
+ for(i=0; i<(DevOrder->Length-2)/sizeof(UINT16); i++)
+ {
+ TRACE((-1,"%x ", OrderData[i]));
+ }
+ TRACE((-1,")\n"));
+
+ TRACE((-1,"[FixedBootOrderTSE.c]FixedBootSetupData DeviceType:%x (:", DevOrder->Type));
+ for(i=0; i<(DevOrder->Length-2)/sizeof(UINT16); i++)
+ {
+ if( i >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM) break;
+
+ Index=NVramOrderIndex[i];
+ if(Index >= FIXED_BOOT_ORDER_SUBMENU_MAX_NUM)
+ break; //is Disable
+
+ TRACE((-1,"%x ",Index));
+ NewOrderData[i]= OrderData[Index] & 0xff;
+ SetBootVariable( NewOrderData[i], TRUE); //set boot#### enable.
+ OrderData[Index]=0xffff;
+ }
+
+#if FIXED_BOOT_INCLUDE_DISABLED_OPTION
+ //Check Disable Item and SetMask
+ if(i<(DevOrder->Length-2)/sizeof(UINT16))
+ {
+ UINTN j;
+ TRACE((-1,"Disable: "));
+ for(j=0;j<(DevOrder->Length-2)/sizeof(UINT16);j++)
+ {
+ if(OrderData[j] == 0xffff) continue;
+
+ TRACE((-1,"%x ", OrderData[j]));
+ NewOrderData[i]= OrderData[j] | 0xff00; //(EIP129692.2)
+ SetBootVariable( OrderData[j], FALSE); //set boot#### disable.
+ i++;
+ }
+ }
+#endif
+ TRACE((-1,"\n"));
+
+ NewDevBuffer = (LEGACY_DEVICE_ORDER*)((UINT8*)NewDevBuffer
+ + NewDevBuffer->Length
+ + sizeof(NewDevBuffer->Type));
+ }
+
+ Status = pRS->SetVariable(L"UefiDevOrder", &FixedBootOrderGuid, Attr, Size, NewDevBuffer2);
+
+ pBS->FreePool(DevOrderBuffer);
+ }
+
+ if( NewDevBuffer2 )
+ pBS->FreePool(NewDevBuffer2);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FixedBootOrderLoadedConfigDefaults
+//
+// Description: TSE LoadDefault ELINK Hook.
+//
+// Input:
+// None
+// Output:
+// None
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+FixedBootOrderLoadedConfigDefaults(IN void)
+{
+ EFI_STATUS Status;
+ SETUP_DATA *pSetupData;
+ UINT16 i, DevMapDataCount;
+
+ EFI_GUID FixedBootOrderSetupGuid = FIXED_BOOT_ORDER_SETUP_GUID;
+ EFI_FIXED_BOOT_ORDER_SETUP_PROTOCOL *pFBOSetup=NULL;
+
+ Status = pBS->LocateProtocol( &FixedBootOrderSetupGuid, NULL, &pFBOSetup );
+
+ if( !EFI_ERROR(Status) )
+ pFBOSetup->load_default_string();
+
+ LoadedDefault=TRUE;
+
+ pSetupData = (SETUP_DATA*)gVariableList[VARIABLE_ID_SETUP].Buffer;
+ //(EIP107268+)>
+#if USE_BCP_DEFAULT_PRIORITIES
+ DevMapDataCount = GetDevMapDataCount(pFBOLegacyDevMap);
+ for(i=0;i<DevMapDataCount;i++)
+ pSetupData->LegacyPriorities[i]=pSetupData->BcpDefaultLegacyPriorities[i];
+
+ DevMapDataCount = GetDevMapDataCount(pFBOUefiDevMap);
+ for(i=0;i<DevMapDataCount;i++)
+ pSetupData->UefiPriorities[i]=pSetupData->BcpDefaultUefiPriorities[i];
+ //(EIP122146+)>
+#if FBO_DUAL_MODE
+ DevMapDataCount = GetDevMapDataCount(pFBODualDevMap);
+ for(i=0;i<DevMapDataCount;i++)
+ pSetupData->DualPriorities[i]=pSetupData->BcpDefaultDualPriorities[i];
+#endif
+ //<(EIP122146+)
+#else //<(EIP107268+)
+ DevMapDataCount = GetDevMapDataCount(pFBOLegacyDevMap);
+ for(i=0;i<DevMapDataCount;i++)
+ pSetupData->LegacyPriorities[i]=i;
+
+ DevMapDataCount = GetDevMapDataCount(pFBOUefiDevMap);
+ for(i=0;i<DevMapDataCount;i++)
+ pSetupData->UefiPriorities[i]=i;
+
+#if FBO_DUAL_MODE
+ DevMapDataCount = GetDevMapDataCount(pFBODualDevMap);
+ for(i=0;i<DevMapDataCount;i++)
+ pSetupData->DualPriorities[i]=i;
+#endif
+
+#endif //(EIP107268+)
+ pSetupData->FBO_Init=1;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SetLegacyDevMap
+//
+// Description: Set Legacy DevMap data to pFBOLegacyDevMap
+//
+// Input:
+// FBODevMap *p
+// Output:
+// EFI_STATUS
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetLegacyDevMap(IN FBODevMap *p)
+{
+ pFBOLegacyDevMap = p;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SetUefiDevMap
+//
+// Description: Set Uefi DevMap data to pFBOUefiDevMap
+//
+// Input:
+// FBODevMap *p
+// Output:
+// EFI_STATUS
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetUefiDevMap(IN FBODevMap *p)
+{
+ pFBOUefiDevMap = p;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SetDualDevMap
+//
+// Description: Set Dual DevMap data to pFBODaulDevMap
+//
+// Input:
+// FBODevMap *p
+// Output:
+// EFI_STATUS
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetDualDevMap(IN FBODevMap *p)
+{
+ pFBODualDevMap = p;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetLegacyDevMap
+//
+// Description: Get Legacy DevMap data.
+//
+// Input:
+// None
+// Output:
+// *FBODevMap
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+FBODevMap *GetLegacyDevMap(IN VOID)
+{
+ return pFBOLegacyDevMap;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetUefiDevMap
+//
+// Description: Get Uefi DevMap data.
+//
+// Input:
+// None
+// Output:
+// *FBODevMap
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+FBODevMap *GetUefiDevMap(IN VOID)
+{
+ return pFBOUefiDevMap;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetDualDevMap
+//
+// Description: Get Daul DevMap data.
+//
+// Input:
+// *FBODevMap
+// Output:
+// EFI_STATUS
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+FBODevMap *GetDualDevMap(IN VOID)
+{
+ return pFBODualDevMap;
+}
+
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SetHiiMap
+//
+// Description: Set Uefi DevMap data to pFBOHiiMap
+//
+// Input:
+// FBOHiiMap *p
+// Output:
+// EFI_STATUS
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetHiiMap(IN FBOHiiMap *p)
+{
+ pFBOHiiMap = p;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetHiiMap
+//
+// Description: Get HiiMap data.
+//
+// Input:
+// None
+// Output:
+// *pFBOHiiMap
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+FBOHiiMap *GetHiiMap(IN VOID)
+{
+ return pFBOHiiMap;
+}
+
+ //(EIP123284+)>
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: SetBootOptionTokenMap
+//
+// Description: Set BootOptionTokenMap data
+//
+// Input:
+// UINT16 *p
+// Output:
+// EFI_STATUS
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetBootOptionTokenMap(IN UINT16 *p)
+{
+ pBootOptionTokenMap = p;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetBootOptionTokenMap
+//
+// Description: Get BootOptionTokenMap data.
+//
+// Input:
+// None
+// Output:
+// *UINT16
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 *GetBootOptionTokenMap(IN VOID)
+{
+ return pBootOptionTokenMap;
+}
+ //<(EIP123284+)
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FBOSetNewDescription
+//
+// Description: Set New Description data
+//
+// Input:
+// FBO_DEVICE_INFORM *p
+// Output:
+// EFI_STATUS
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetNewDescription(IN FBO_DEVICE_INFORM *p)
+{
+ if (pFBONewDevDescription == NULL)
+ {
+ pFBONewDevDescription = p ;
+ return EFI_SUCCESS ;
+ }
+ else
+ {
+ FBO_DEVICE_INFORM *DevInfom = pFBONewDevDescription ;
+ while( DevInfom->Next )
+ DevInfom = DevInfom->Next ;
+ DevInfom->Next = p ;
+ return EFI_SUCCESS ;
+ }
+
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: GetNewDescription
+//
+// Description: Get New Description data.
+//
+// Input:
+// None
+// Output:
+// *FBO_DEVICE_INFORM
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+FBO_DEVICE_INFORM *GetNewDescription(IN VOID)
+{
+ return pFBONewDevDescription;
+}
+
+static EFI_FIXED_BOOT_ORDER_PROTOCOL gFixedBootOrderProtocol =
+{
+ SetLegacyDevMap,
+ SetUefiDevMap,
+ SetDualDevMap,
+ SetHiiMap,
+ SetBootOptionTokenMap, //(EIP123284+)
+ SetNewDescription,
+ GetLegacyDevMap,
+ GetUefiDevMap,
+ GetDualDevMap,
+ GetHiiMap,
+ GetBootOptionTokenMap, //(EIP123284+)
+ GetNewDescription
+};
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+//
+// Procedure: FBO_Protocol_install
+//
+// Description: Initialize EFI_FIXED_BOOT_ORDER_PROTOCOL function service.
+//
+// Input:
+// None
+// Output:
+// None
+// Modified:
+// None
+// Referrals:
+// None
+// Notes:
+//
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void FBO_Protocol_install(IN void)
+{
+ EFI_HANDLE Handle = NULL;
+ EFI_GUID FixedBootOrderGuid = FIXED_BOOT_ORDER_GUID;
+ EFI_STATUS Status;
+
+ Status = pBS->InstallProtocolInterface (
+ &Handle,
+ &FixedBootOrderGuid,
+ EFI_NATIVE_INTERFACE,
+ &gFixedBootOrderProtocol
+ );
+
+ // Install protocol interface
+ TRACE((-1,"Install FixedBootOrder protocol (%r)\n", Status));
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************